/*
Unique Adhikari
*/
#include<iostream>
#include<string>
using namespace std;
class author
{
string name, qualification;
public:
void getdata()
{
cout<<"Enter author name: ";
getline(cin>>ws, name);
cout<<"Enter author qualification: ";
getline(cin>>ws, qualification);
}
void putdata()
{
cout<<"Author name is "<<name<<", whose qualification is "<<qualification<<endl;
}
};
class publication
{
string pname;
public:
void getdata()
{
cout<<"Enter publication name: ";
getline(cin >> ws, pname);
} //Code by: UNIQUE ADHIKARI
void putdata()
{
cout<<"Publication name: "<<pname<<endl;
}
};
class book : public author, public publication
{
string title;
int price;
public:
void getdata()
{
author::getdata();
publication::getdata();
cout<<"Enter book titel: ";
getline(cin>>ws, title);
cout<<"Enter book price: ";
cin>>price;
}
void putdata()
{
author::putdata();
publication::putdata();
cout<<"The price of "<<title<<" book is "<<price<<"/-"<<endl;
}
};
int main()
{
book b;
cout<<"Input=>\n";
b.getdata();
cout<<"...............................\n";
cout<<"Output=>\n";
b.putdata();
return 0;
}
Coding Sample
December 31, 2022