ehb
asked on
using dynamic CArray -- need an array of structures
I am designing a CVideoList class which will hold the an
array of this structure:
struct Video
{
CString title;
int have; int want;
int inventory_number;
int noWaiting;
<<a dynamic array which will hold :
struct waitListEntry
{
CString waitName;
CString contact;
} waitList;
>>>>>
}
my trouble is :
1) when I compile, I find that CString is undefined
2) I understand how to use the templated class CArray
please explain:
1) which files to #include in my class header file
2) how to use dynamic CArray template class
Thank you in advance for your help.
array of this structure:
struct Video
{
CString title;
int have; int want;
int inventory_number;
int noWaiting;
<<a dynamic array which will hold :
struct waitListEntry
{
CString waitName;
CString contact;
} waitList;
>>>>>
}
my trouble is :
1) when I compile, I find that CString is undefined
2) I understand how to use the templated class CArray
please explain:
1) which files to #include in my class header file
2) how to use dynamic CArray template class
Thank you in advance for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could you please expound upon deriving from CObject? Can I do this for any class I want?
I took a college level OODesign/Implementation class and deriving from CObject was never mentioned.
Thank you very much for your help!
Eric
I took a college level OODesign/Implementation class and deriving from CObject was never mentioned.
Thank you very much for your help!
Eric
There is no need at all to derive from CObject - don't do it unless you really need the serialization.
You use the CArray<> (or CList<> or CMap<>) template classes.
These work equally well with non-CObject classes.
See my earlier comment .. Or better (for me) ask another question so I can ansewr it :-)
You use the CArray<> (or CList<> or CMap<>) template classes.
These work equally well with non-CObject classes.
See my earlier comment .. Or better (for me) ask another question so I can ansewr it :-)
CArray<data-type, arg-type>
eg.
CArray<waitListEntry,const
this means each item in the array is a 'waitListEntry' and the member function args are 'const waitListEntry&'. For example, the template will expand to include a member function
void SetAtGrow( int nIndex, const waitListEntry& newElement );
note that 'const waitListEntry&' was used to pass an element in/out.
See the on-line help for examples (as per the answer proposed)