|
-
February 23rd, 2009, 11:09 PM
#1
Multi-inheritance Polymorphism
Suppose my code is setup like this:
Code:
class A
{
};
class B
{
};
class C : A,B
{
};
A* someFunction()
{
return (A*) new C;
}
Notice I've casted a C into an A. C inherits A, but also B. Is this safe to do if I still know what type it is and cast it back latter, or does multi-inheritance bring up problems with polymorphism? As a second part to my question, would it also be okay to cast from C to B? In other words, does their order in the inheritance area of C's class definition matter, or can you only revert to the first inherited class? Thanks in advance.
Tags for this Thread
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
|