Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me........in c++

Status
Not open for further replies.

jyotsna24

Programmer
Jun 24, 2001
15
0
0
IN
Hi,
I have to do a program,that is using inheritance.There is a base class person and two derived classes,worker and manager.I have to enter the details of the person.The details of worker and manager are same except salary.i.e.,name designation etc.we can write a function to get the details in the base class. But the salary calculation should be done in the derived class itself.shouldn't ? And should display these details. If the person is a worker we should calculate the salary in the worker class.If the person is a manager salary should calculate in the manager class.At last the result,i.e., name,designation and salry sould be diplayed.
How this classes' object should be connected to diplay all the details?
Please help me as soon as possible.I would be very thankful to u if I provide a solution to this priblem.
Thanks a lot.
 
the person class should contain the salary function as a pure virtual function

class person{
public:
virtual int salary()=0;
...

};

the worker and manager classes inherit from person and define their own salary function. When the function is called, it will know which one to call

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top