Some questions of Inheritance
I define my classes as follow
class A
{
};
class B : public A
{
public:
void functionB(void);
};
main()
{
A* objectB=new B;
objectB->functionB(); // this should be OK
A* objectA=new A;
((B*)objectA)->functionB(); // this is OK too, why?
}
suppose functionB() is the member of class B, it shouldnt be right to be called by A object. However I did it no problem, why?
Any side effect if I do this?
Re : Pete <dynamic_cast error>
I tried dynamic_cast. Its too bad, compile error!
I have tried static_cast, and reinterpret_cast, they are OK, but not dynamic_cast and const_cast.
I will do further reading on casting.
Thank you to all of you. HAVE A NICE DAY!!!!