Inheritance question

Hey guys,

This week in my CS class I'm learning about inheritance. We are asked draw 3 UML diagrams (one base, and 2 sub-classes).

Let's say the base class is for an Employee object.
If it has a func +calcPay() would I also have to write this function into the UML for the two sub-classes in their respective functions lists? Or is it not needed because it is inherited?

My gut says I do, but the instructions I was given state that only "unique" things are placed into the UMLs of sub-classes. I feel like they are unique because they will calculate differently based on the type of employee even though the functions have the same name.
This is how I would consider the situation:

If they use the same function, with the same functionality between the base class and sub-classes --> put it into the base class only

If they use the same function, but with different functionality for each sub-class --> put it in for each class.

http://www.cplusplus.com/doc/tutorial/polymorphism/

This will help understand more about it (look into virtual members).

I hope this is helpful.
@crimsonzero2
Thank you! That logic makes sense. Bookmarking that link.
No problem =)
Topic archived. No new replies allowed.