The MFC's CArray is defined as:
template< class TYPE, class ARG_TYPE > class CArray : public CObject
Why is there the need for two arguments? whats the purpose of the 2nd?
thanks
Q
Printable View
The MFC's CArray is defined as:
template< class TYPE, class ARG_TYPE > class CArray : public CObject
Why is there the need for two arguments? whats the purpose of the 2nd?
thanks
Q
The second parameter is used in some member functions like :CArray::Add or CArray::SetAt.
It specifies the type used to reference objects stored in the array. This is the reason....
Hi!
You need it for copy operations and so.
It as simple as
CArray<int,int&> m_YourArray;
or your own type:
struct t_YourType
{
//Your variables
};
CArray <t_YourType, t_YourType&> m_YourArray;
Hope it helps,
Toni
I can barely understand MSDN help for CArray as to what the second parameter is used for. This is why I use the standard STL vector<> class. No messing around -- just say what type is in the vector, and that's it. If I were you, I would also use the standard C++ collection classes (like vector, list, and map) and let MFC collections go by the wayside.
I could never see the reason for the second argument in CArray, unless the underlying CArray code needs this argument to "help it" to do certain things. If this is the case, this is a design flaw in the CArray class.
Regards,
Paul McKenzie