#include<conio.h>
using namespace std;
class media{
protected:
char title[50];
char pub[50];
public:
virtual void read()=0;
virtual void show()=0;
};
class book:public media {
private:
int pages;
public:
void read(){
cout<<"Book details"<<endl;
cin>>title;
cin>>pub;
cin>>pages;
}
void show(){
cout<<"Title"<<title;
cout<<"Publication"<<pub;
cout<<"Pages"<<pages;
}
};
class tape:public media {
int time;
public:
void read(){
cout<<"Tape details"<<endl;
cin>>title;
cin>>pub;
cin>>time;
}
void show(){
cout<<"Title"<<title;
cout<<"Publication"<<pub;
cout<<"Time"<<time;
}
};
int main(){
media *m;
book b;
tape t;
m=&b;
m->read();
m->show();
m=&t;
m->read();
m->show();
getch();
return 0;
}
0 comments:
Post a Comment