Develop a code for the multiple inheritance diagram given below
· The publisher base class consisting of data members such as pname and place, and member functions get() and display().
· The author base class consisting of data members such as aname, and member functions get() and display().
· The book derived class inherits the two base class publisher and author consisting of data members such as title, price and pages, and member functions get() and display().
#include<iostream>
using namespace std;
class publisher{
public:
String pname;
String place;
get(){
cout<<"method to get the value "<<endl;
}
display(){
cout<<"method to display the value "<<endl;
}
};
class author{
public:
String aname;
get(){
cout<<"method to get the value "<<endl;
}
display(){
cout<<"method to display the value "<<endl;
}
};
class book: public publisher, public author{
public:
String title;
int price;
int pages;
get(){
cout<<"method to get the value "<<endl;
}
display(){
cout<<"method to display the value "<<endl;
}
};
int main(){
book obj;
return 0;
}
Comments
Leave a comment