I've been searching but couldn't find an answer to this. Is there a way to tell the new
operator to not call the class constructors?
MyObject* array = new MyObject[1000];
This will call MyObject()
a thousand times! I want to fill the allocated memory myself and do not need any information initialized in the constructor. Using malloc()
is not very harmonic C++ code imho.
MyObject* array = (MyObject*) malloc(sizeof(MyObject) * 1000);
static_cast
? The construction syntax was new to me. Speed is the key, I don't think a map suits since I really need a linear array of a fixed number of elements. – Sunbonnet