Page 179 - DCAP404 _Object Oriented Programming
P. 179
Object-oriented Programming
Notes
Did u know? What is directed acyclic graphs?
Directed acyclic graphs are not unique to single inheritance. They are also used to depict
multiple-inheritance graphs.
The following program shows the single inheritance by private derivation.
#include<iostream.h>
#include<conio.h>
class worker //Base class declaration
{
int age;
char name[10];
public:
void get();
void show();
};
void worker::get()
{
cout<<“\nYour name please:”;
cin>>name;
cout<<“\nyour age please:”;
cin>>age;
}
void worker : show()
{
cout << “\nMy name is: “<<name<< “\n” << “My age is: “<<age;
}
class manager : worker //Derived class (privately by default)
{
int now;
public:
void get();
void show();
};
void manager::get()
{
worker::get(); //calling the get function of base
cout<<“number of worker under you”;
172 LOVELY PROFESSIONAL UNIVERSITY