What's the difference between these 2 lines
CArray<MyClass, MyClass> MyArray
CArray<MyClass, const MyClass & > MyArray
What's the difference between these 2 lines
CArray<MyClass, MyClass> MyArray
CArray<MyClass, const MyClass & > MyArray
The MyClass is always copied to the array. But the first form copies it twice: the first time when its given as a parameter to the Add or SetAt function, the second time internally. With the second form you avoid the first copy.
In the first case you need to have accessable copy constructor in
MyClass
, andMyClass
will be passed by value (copied) in some members ofCArray
( inCArray::Add
for instance).