1.) What is the difference between
CArray <SomeClass> collection;
and
CArray <SomeClass,SomeClass> collection;
or even
CArray <SomeClass* ,SomeClass* > collection;
?
2.) While reading some comments on Stackoverflow I came to a note saying “Don’t use CArray”. Why should CArray not be used?
This:
is equivalent to this:
The second template parameter is used to specify the type through which members are accessed. The template parameters are described in the documentation on MSDN.
This:
stores a collection of pointers to objects of type
SomeClass, whereas the other two store collections of objects of typeSomeClass.As for why you “shouldn’t use it,”
std::vector, which is part of the C++ language standard, and thus portable, is probably a better choice for most projects. If you have legacy code that usesCArray, then you may need to use it, and there’s nothing wrong with that.