|
-
June 20th, 2001, 08:57 AM
#1
CArray arguments
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
-
June 20th, 2001, 09:22 AM
#2
Re: CArray arguments
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....
-
June 20th, 2001, 09:31 AM
#3
Re: CArray arguments
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
-
June 20th, 2001, 02:49 PM
#4
Re: CArray arguments
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
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
|