I have a base class (call it A) from which I have several derived classes. A has a CArray<A*> data member (dynamic array of pointers to A objects). When adding an object of B (class derived from A), none of B's data members show up when the object is accessed from the CArray of the first A object. Apparently, the B object is not being copied somehow. I'm currently using this code:
class A
{
A() {}
void AddChild(A* child)
{
m_aryChildren.Add(child);
}
CArray<A*> m_aryChildren;
}
class B : public A
{
B()
{
A::AddChild(new A());
}
}
// ....
A aobject();
aobject.AddChild(new B(5, 7));
int size = aobject[0].m_aryChildren.GetSize();
the 'size' variable should be 1. Yet it's showing up as zero, as if the B object I passed never had any of its data members set. Does anyone know what the problem is?