And if it is an array of int, it will also fail. So your code doesn't accomplish anything except potentially corrupt memory. An object is still created and/or assigned to, and will corrupt memory if any operations are done on it.Quote:
Originally Posted by aewarnick
If you don't want copying, then you make these functions private.
If you just used new[] instead of malloc(), then you don't worry about POD versus non-POD, since new[] will construct x objects correctly. But ultimately, the best thing to do is just to use vector<T*>. I mean look at your own comment:Quote:
I guess the best thing to do would be to code an array that is used strictly for pointer types in this case.
There is absolutely no reason to code your own class given this. All you needed to do is use vector<T*> if there was a degradation in speed using a vector<T>. I'm starting to wonder if you were even using the vector<T> correctly, i.e. passing it as a parameter or returning it, since you made it clear you didn't know what const was, which is a fundamental concept in C++.Quote:
//The reason I created it this way is for speed. Otherwise, every time the array needs copied for
//reasons such as removing, inserting, resizing...classes would be created and then all the members copied
Regards,
Paul McKenzie
