|
-
February 11th, 2011, 06:11 PM
#1
Best way to store an array of pointers
Hi
I have usually created stuff in Visual Studio 6.0 but have now moved on to Visual Studio 2010. The compiler are more strict and I have trouble using "old hacks" and need to learn something new..
I have three classes; A an MFC based class and B & C which is Non-MFC.
In A I have a CPtrArray list over pointers of class B, this works as in VS6.0
In B I tried CPtrArray for class C, but since it is not MFC I get an error saying:
error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'
(...)
This diagnostic occurred in the compiler generated function 'CPtrArray::CPtrArray(const CPtrArray &)'
So I tried vector<ClassC *> m_myclassC;
But this one is **** slooow and I figured it out since it called the copy-function ClassB (const ClassB & v) then the destructor. And since each class uses some GDI+ stuff it is doing its work several times.
Isn't the vector<void *> be equal to CPtrArray? If so, why does it call the copy & destructor all the time. Any advice would be great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|