Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

QUESTION#01:

#include<iostream>

#include<string>

using namespace std;

class person

int id;

string name,address;

public:

person() {}

void input()

cout<<"Enter Name: ";

cin>>name;

cout<<"Enter ID: ";

cin>>id;

cout<<"Enter Address: ";

cin>>address;

void display()

cout<<"Name: "<<name<<endl;

cout<<"ID: "<<id<<endl;

cout<<"Address: "<<address<<endl;

}
};

class student:public person

int marks;

string rollno;

public:

void set_value()

cout<<"Enter roll number: ";

cin>>rollno;

cout<<"Enter marks: ";

cin>>marks;

void show()

cout<<"Roll Number: "<<rollno<<endl;

cout<<"Marks : "<<marks<<endl;

};

int main()

student obj;

obj.input();

obj.set_value();
cout<<"\nShowing Data!"<<endl<<endl;

obj.display();

obj.show();

QUESTION#02:

#include<iostream>

#include<string>

using namespace std;

class employee

int employeeID;

int scale;

public:

void input()

cout<<"Enter Employee ID: ";

cin>>employeeID;

cout<<"Enter Employee scale: ";

cin>>scale;

void show()

cout<<"Employee's ID : "<<employeeID<<endl;

cout<<"Employee's Scale : "<<scale<<endl;


}

};

class manager:public employee

string department;

int managerID;

public:

void set_value()

cout<<"Enter manager ID: ";

cin>>managerID;

cout<<"Enter manager Department: ";

cin>>department;

void display()

cout<<"Manager ID: "<<managerID<<endl;

cout<<"Manager Department: "<<department;

};

int main()

manager obj;

obj.input();

obj.set_value();
cout<<"\nShowing Data!\n"<<endl;

obj.show();

obj.display();

QUESTION#03:

#include<iostream>

#include<string>

using namespace std;

class localphone

string phone;

public:

void InputPhone()

cout<<"Enter phone number: ";

cin>>phone;

void ShowPhone()

cout<<"Phone Number is: "<<phone<<endl;

};

class netphone: public localphone

string city;
public:

void InputCity()

cout<<"Enter city code: ";

cin>>city;

void ShowCity()

cout<<"City Code is: "<<city<<endl;

};

class intphone: public netphone

string country;

public:

void InputCountry()

cout<<"Enter country Code: ";

cin>>country;

void ShowCountry()

cout<<"Country code is: "<<country<<endl;

};
int main()

intphone obj;

obj.InputPhone();

obj.InputCity();

obj.InputCountry();

cout<<"\nShowing Data!\n"<<endl;

obj.ShowPhone();

obj.ShowCity();

obj.ShowCountry();

QUESTION#04:

#include<iostream>

#include<string>

using namespace std;

class teacher

string name,address;

int age;

public:

void set()

cout<<"Enter Data of Teacher!\n"<<endl;

cout<<"Enter name: ";

cin>>name;
cout<<"Enter age: ";

cin>>age;

cout<<"Address: ";

cin>>address;

void show()

cout<<"Name of Teacher: "<<name<<endl;

cout<<"Age of the Teacher: "<<age<<endl;

cout<<"Address of Teacher: "<<address<<endl;

};

class writer

string namew;

string address_writer;

int books;

public:

void input()

cout<<"\nEnter Data of Writer!\n"<<endl;

cout<<"Enter name: ";

cin>>namew;

cout<<"Enter books: ";

cin>>books;
cout<<"Address: ";

cin>>address_writer;

void display()

cout<<"\nName of Writer: "<<namew<<endl;

cout<<"Books of the Writer: "<<books<<endl;

cout<<"Address of Writer: "<<address_writer<<endl;

};

class scholar:public writer,public teacher

};

int main()

scholar obj;

obj.set();

obj.input();

cout<<"\nShowing Data!\n"<<endl;

obj.show();

obj.display();

You might also like