0% found this document useful (0 votes)
8 views

Inheritance

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Inheritance

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream>

using namespace std;


class publication{
int price;
char title[20];
public:
void get(){
cout<<"enter title:";
cin>>title;
cout<<"enter price:";
cin>>price;
}
void put(){
cout<<"title is:"<<title<<endl;
cout<<"price is:"<<price<<endl;
}
};
class book:public publication{

int p_cnt;
public:
void getb(){
try
{
get();
cout<<"enter the page count:";
cin>>p_cnt;
if (p_cnt==0){
throw p_cnt;
}
}
catch(...){
cout<<"invalid page count:"<<endl;
p_cnt=0;
}
}
void putb(){
cout<<"page count is:"<<p_cnt<<endl;

}
};
class tape:public publication{
float p_time;
public:
void getp(){
cout<<"Enter the play time:";
cin>>p_time;
}
void putp(){
cout<<"play time is:"<<p_time<<endl;
}
};
int main(){
book b;
tape t;
cout<<"SHRUTI KIRAN JADE"<<endl;
b.getb();
b.putb();
t.getp();
t.putp();

return 0;

You might also like