What are the PRO's/CON's of doing the following
in relation to each other
Code:STL container of MyClass* such as std::vector<MyClass*> or STL container of MyClass such as std::vector<MyClass>
What are the PRO's/CON's of doing the following
in relation to each other
Code:STL container of MyClass* such as std::vector<MyClass*> or STL container of MyClass such as std::vector<MyClass>
If you need to use different containers to store exactly the same elements then a containers of MyClass*'s are necessary, and they'll probably be faster in some respects as the STL containers often copy elements from one location to another. The cost of copying a pointer will probably be less than having MyClass's copy constructor called.
However, containers of MyClass*'s can be trickier as you always have to ensure that the pointers point to valid locations and you'll probably have to manage memory yourself unless you implement a smart pointer.