|
-
March 18th, 2009, 09:54 AM
#1
Class Inheritance Question
Hey there,
Just a quick question about class inheritance:
If I have a class C that inherits from both class A and class B.
Class A and class B have a virtual function called foo()
To avoid issues in class C I would put this as the declaration as C::foo()
Code:
virtual void C::foo(){ A::foo(); }
To make sure it ran A's foo() instead of B's
Is this the correct way to do things? Or should I declare B's foo() without the virtual directive? Even if A's data members are declared as protected and are easily accessible in class C. Should I leave them both as virtual in class A and B and just copy class A's foo() into class C's foo()?
I guess what I'm asking is what normally happens in this situation.
Thanks,
Lang
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
|