Declaring CArray HELP!
Posted on 2000-03-10
I have a class CBase and classes CDerived1 and CDerived2 which are both derived from CBase as Public.
I am trying to declare CArray to contain pointers to the base class CBase. The pointers will either point to CDerived1 or CDerived2. From the CArray I want to return CBase pointer then call virtual functions to execute methods of either CDerived1 or CDerived2, depending which one the pointer was pointing to. My declaration looks like this:
CArray<CBase, CBase*) BaseArray;
This seems to fail as:
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(443) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CBase *' (or there is no acceptable conversion)
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member function 'void __thiscall CArray<class CBase,class CBase *>::SetAtGrow(int,class CBase *)'
Error executing cl.exe.
What am I doing wrong? How can I declare correctly and also please show me how to declare the derived classes, point CBase pointer to the derived class object and put the base pointer in the array