Coder's Guild Mailing List

MFC question: CArray

Posted by Fox on 2000-02-12

I have this class called:

class CFeatureRect : public CRect


CFeatureRect has a few classes derived from it, defined below:

class CLine : public CFeatureRect
class CEllipse : public CFeatureRect
etc...

Is it possible to have a CArray object like this:

CArray<CFeatureRect, CFeatureRect &> shape;

..and then store a CLine, or a CEllipse object on this array?

shape.SetAtGrow(0, CLine(...));


	In other words, is it legal, safe and usable, to store derived classes on an 
array defined to hold their base classes?

	If this is possible, can I access any data fields, functions, etc; that are on the 
stored derived class but aren't on the base class and vice versa?  Is everything 
accessable when I store a derived class on there?
________________________________________________________
Signed: Fox
        sfox@xxxxxxxx.xxx

Unbeknowst to most computer users, the "Hertz" is the unit
of measurement for how much faster and smarter the computer
is compared to you.
To signoff send a mail to listserver@xxxx.xx.xx with 
  "signoff tcg" in the body of your message.