I want to call the constructor;
class anAbstractClass
{
public: anAbstractClass(inputdatatype){/*blablabla*/}
};
class aChield : public anAbstactClass
{
/*
...
*/
}
void _engine::initShader(_anAbstractClass** inShader)
{
*inShader = new /*???*/(inputdata for the construcor)
}
aChield* theChield;
_engine* myEngine = new _engine();
myEngine->initShader(&theChield);
So, how can I call the constructor at the /???/?
Thx ahead for the answers!
Nice idea, but there is no support to get the exact type of a pointer at runtime.
In your
initShadermethod,inShaderis of typeanAbstractClass**and there is no way to get the information that it was a pointer to pointer to a derived class before the method call.So you need the change your code, maybe you can use some Factory or something like this.