Tony Johansson wrote:[color=blue]
> Hello Experts!!
>
> Here we use multiple inheritance from two classes.We have a class named
> Person at the very top
> and below this class we have a Student class and an Employee class at the
> same level.
> There is a class TeachingAssistent that use multiple inheritance from both
> Student and Employee.
> There is a method named getName is class Person.
>
> Now to my question which is a question about design.
>
> Would it be any point to define this method getName as virtual so the
> derived classes could override this method which would result to a possible
> use of polymorfism.[/color]
The overriding does not allow you to use polymorphism. It allows you to override the GetName function if you need to change the implementation.
The problem you have is that in TeachingAssistant, you actually have two GetNames... inherited from the two Persons.
You must be careful of the diamond-shaped inheritance diagram. Consider making Person a Pure ABC.
Don't use inheritance for code-reuse, use it if you require the flexibility of polymorphism.
And read the FAQ on Multiple Inheritance:
http://www.parashift.com/c++-faq-lit...heritance.html
Ben
--
I'm not just a number. To many, I'm known as a String...