#include<iostream>
using namespace std;
class Teacher
{
protected:
string theacher_name,address;
int age;
public:
void inputdata(string x,string y,int z)
{
theacher_name=x;
address=y;
age=z;
}
void displaydata();
};
void Teacher::displaydata()
{
cout<<"the name of the teacher is:"<<theacher_name<<endl;
cout<<"the address of the teacher is:"<<address<<endl;
cout<<"the age of the teacher is:"<<age<<endl;
}
class Author
{
protected:
string author_name,address;
int written_books;
public:
void inputdata(string x,string y,int z)
{
author_name=x;
address=y;
written_books=z;
}
void displaydata();
};
void Author::displaydata()
{
cout<<"the name of the author is:"<<author_name<<endl;
cout<<"the address of the author is:"<<address<<endl;
cout<<"number of books written by author are:"<<written_books<<endl;
}
class Scholar:public Teacher,public Author
{
private:
string Scholar_name;
public:
void inputdata(string x)
{
Scholar_name=x;
}
void displaydata()
{
cout<<"the scholar name is:"<<Scholar_name<<endl;
}
};
int main()
{
Scholar obj1;
obj1.Teacher::inputdata("hamza","isakhel",18);
obj1.Teacher::displaydata();
obj1.Author::inputdata("hamza"," mainwali",45);
obj1.Author::displaydata();
obj1.inputdata("ali");
obj1.displaydata();
}
No comments:
Post a Comment