Write a program for a publishing company that markets both printed books and audio visual
lectures stored on CDs. Write a class Publication thatstores title and price. Derive a class book which
has an additional member as no_pages and a class Lecture with member play_time.
#include<iostream>
using namespace std;
class Publication {
private:
string title;
float price;
public:
void input(){
cout<< "Enter the Title:\t ";
cin >> title;
cout << "Enter the Price: \t" ;
cin >> price;
}
void Output() {
input();
cout << "The title of the book: " << title << endl;
cout << "The price of book: " << price <<endl;
}
};
class Book: public Publication{
private:
int no_pages;
public:
void InputPages(){
cout<<"Enter number of pages\t";
cin>>no_pages;
}
void displayPage(){
Output();
InputPages();
cout<<"The book number of pages is\t"<<no_pages<<endl;
}
};
class Lecture: public Publication{
private:
float play_time;
public:
void inputTime(){
cout<<"Enter the play time \t";
cin>> play_time;
}
void displayTime(){
inputTime();
cout<<"The play time is\t"<<play_time<<endl;
}
};
int main(){
Book b;
b.displayPage();
}
Comments
Leave a comment