paulsdsrubbish,
Thanks for the reply. I think you assumed I knew less C++ than I do since my question was syntactical =) However it is imperative that the default constructors are avoided. Thanks for the suggestions though. Maybe I''m misstaken in my replies, if so, please correct me =)
quote:
there are special tags you can use on this forum that format code properly.
And they were used =) Maybe I should have used the source tags instead of the code ones but I used them for readability.
quote:
Point3 mP[3];
... is just declaring a pointer to an array, not the array itself.
Actually that seems wrong to me. The default constructors are run thus the array is fully declared. I think the standard guarantees that each member variable be available and available in the order declared, once the constructor body is run. Pointers would not cause the constructors to be executed.
quote:
I can see you are trying to be smart and do it in the initaliser list, which is admirable but also wrong
Well most code I see initializer lists are used extensively in order to avoid the extra call to the default constructor. Then again most code I see may be wrong.
quote:
so first
mp = new Point3[3];
No thanks. I don''t want it on the heap. Nor do I want the default constructors to run. more correct would be:
mP = new Point3[] = { Point3(...), Point3(...), Point3(...) };
But that still leaves the heap issue. Since I''m using objects required by the processor to be 16-byte aligned, allocating on the heap is somewhat expensive not to mention it should generally be avoided in code used as often as my primitives are.
quote:
Also be warey of optimising before you know there is a bottleneck. Get it done, if there''s a bottleneck you can find it and deal with it later.
The problem is these are base objects and are getting constructed/destroyed all the time. Of course if the default constructor is empty the call will be optimised away.
I''m starting to believe there is no way to do what I want unless I use a std::vector for my array but that''s out of the question. The only way to solve this seems to be to separate the array member mP into 3 variables mP0, mP1, mP2. This is exactly what I wanted to avoid. Anyone who knows the best way to solve the issue? Hopefully I''m not being a total moron =)