inheritance

ive written the code as required but im confused at this ques"
In main, create object of “ITManager” and pass the values for all the data members: ITManager obj(age,name,empId,salary,type,noOfPersons); "
Im confused at how to initialize members of base class using object of derived class.


#include<iostream>
using namespace std;

class Person{

private:
int age;
protected:
string name;
public:
void set(int d,int c){
age=d;
name=c;
}
void display(){
cout<<"Name of employee:"<<name<<"\n";
cout<<"Age of employee:"<<age<<"\n";

}

};
class Employee{
private:
int empld;
protected:
int salary;
void set(int a,int b){
empld=a;
salary=b;
}
void display(){
cout<<"Employee id:"<<empld<<"\n";
cout<<"Employee salary:"<<salary<<"\n";
}
};
class Manager:public Person,public Employee
{
private:
string type;
public:
void set(string b){
type=b;
}
void display(){
cout<<"Type is:"<<type<<endl;
}
};
class ITManager:public Manager {

private:
int noOfpersons;
public:
void set(int h){
noOfpersons=h;
}
void Display(){
Manager::display();
cout<<"The no of persons are:"<<noOfpersons<<endl;

}
};
int main(){

ITManager ob;javascript:PostPreview()

}
Registered users can post here. Sign in or register to post.