liam mail | 4 Dec 02:46

Re: How can base class pointers to a derived object be used as a derived object pointer?

2008/12/4 James Masters <james.d.masters <at> gmail.com>:
> Hi all,
>
> First off, I'm fairly new to both C++ and SWIG so I apologize ahead of time
> if something is wrong with my examples or if this is a newbie question.  I'm
> at a bit of a loss as to how to even form my question, so maybe I'll just
> explain what I'm trying to accomplish using a simplified example.
>
> I have the following classes where I have a "definition" class for a polygon
> (PolygonDef) and a rectangle (Rect which derives from PolygonDef).
> Furthermore, I have a Rect class that constructs with a RectDef object
> reference as an argument.  So the headers would be as follows:
>
> /******************** inhtest.h ********************/
>
> //// HEADERS ////
>
> class PolygonDef {
>  public:
>   static PolygonDef * find();
> };
>
> class RectDef : public PolygonDef {};
>
> class Rect {
> public:
>   int data;
>   Rect(int);
>   static Rect * create(const RectDef &rd);
> };
(Continue reading)


Gmane