Hello
This is my base
class BaseClass
{
// base has no body
};
and child
class ChildClass : public BaseClass
{
public:
void testMethod();
};
I do
BaseClass* base = new BaseClass();
ChildClass* c = static_cast<ChildClass*>(base);
c->testMethod();
Above compile and ChildClass::testMethod() executes fine.
my memory is allocated by BaseClass (new BaseClass()), but I can cast it to ChildClass* and executes fine.
How is this possible? Is it auto initializ everything for ChildClass with static_cast?