T
Tristan
I have a function:
AbstractClass* getObject()
{
AbstractClass* d = new DerivedClass;
return d;
}
What I want is for this function to return an
actual instance of the derived class not a
pointer to it. This can't be done because the
function can't be declared as
AbstractClass getObject()
Inside this function I will be declaring the derived
type based on a code read from a file which is
why the correct object must be created and returned.
If there is no workaround how could the memory
declared by new DerivedClass be freed after
getObject has been used in the calling code?
Many Thanks
Tristan.
AbstractClass* getObject()
{
AbstractClass* d = new DerivedClass;
return d;
}
What I want is for this function to return an
actual instance of the derived class not a
pointer to it. This can't be done because the
function can't be declared as
AbstractClass getObject()
Inside this function I will be declaring the derived
type based on a code read from a file which is
why the correct object must be created and returned.
If there is no workaround how could the memory
declared by new DerivedClass be freed after
getObject has been used in the calling code?
Many Thanks
Tristan.