I want to write a base class that includes a member function that creates an
instance of a derrived class and returns a pointer to it.
Problem: The derived class definition has to follow the base class
definition. Therefore I can't specify the return type of the function, that
returns a pointer to the derived class, because the derived class is not yet
known at that point.
Hov can I solve this problem? In a nice manner :)
-- Source Code ------------------------------------------------
class myMainClass
{
public:
mySubClass createSubClassI nstance(void);
};
class mySubClass: public myMainClass
{
};
----------------------------------------------------------------------
I'm am looking forward for your clever answer
regards, Teis
instance of a derrived class and returns a pointer to it.
Problem: The derived class definition has to follow the base class
definition. Therefore I can't specify the return type of the function, that
returns a pointer to the derived class, because the derived class is not yet
known at that point.
Hov can I solve this problem? In a nice manner :)
-- Source Code ------------------------------------------------
class myMainClass
{
public:
mySubClass createSubClassI nstance(void);
};
class mySubClass: public myMainClass
{
};
----------------------------------------------------------------------
I'm am looking forward for your clever answer
regards, Teis
Comment