#include <iostream>
#include <string>
using namespace std;
class publication
{
private:
string title;
float price;
public:
publication(){
}
~publication(){}
virtual void getdata()
{
cout << "Enter a title of publication: ";
cin >> title;
cout << "Enter a price of publication: ";
cin >> price;
}
virtual void putdata()
{
cout << "The publication title: " << title << "\n";
cout << "The Publication price: " << price<<"\n";
}
};
class book :public publication
{
private:
int pagecount;
public:
book(){}
~book(){}
void getdata()
{
publication::getdata();
cout << "Enter Book Page Count: ";
cin >> pagecount;
}
void putdata()
{
publication::putdata();
cout << "Book page count: " << pagecount <<"\n";
}
};
class tape :public publication
{
private:
float playingtime;
public:
tape(){}
~tape(){}
void getdata()
{
publication::getdata();
cout << "Enter tape playing time: ";
cin >> playingtime;
}
void putdata()
{
publication::putdata();
cout << "Tape's playing time: " << playingtime << "\n";
}
};
int main(void){
book* newBook=new book();
newBook->getdata();
tape* newTape=new tape();
newTape->getdata();
cout<<"\n";
newBook->putdata();
newTape->putdata();
delete newBook;
delete newTape;
system("pause");
return 0;
}
Comments
Leave a comment