Page 178 - DCAP404 _Object Oriented Programming
P. 178
Unit 9: Inheritance
int now; Notes
public:
void get();
void show();
};
void manager::get()
{
worker::get(); //calling base class get function
cout<<“\nNumber of workers under you”;
cin >> now;
}
void manager::show()
{
worker::show(); //calling base class show function
cout>>”No. of workers under me is: “<<now;
}
main()
{
clrscr();
worker W1;
manager M1;
M1.get();
M1.show();
}
If you input the following to this program:
Your name please
Ravinder
Your age please
27
number of workers under you
30
Then the output will be as follows:
My name is : Ravinder
My age is : 27
No. of workers under me is : 30
LOVELY PROFESSIONAL UNIVERSITY 171