|
-
July 8th, 2002, 02:52 AM
#1
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|