0% found this document useful (0 votes)
38 views3 pages

New Text Document

This C++ program defines classes for publications including book, tape, and disk. It allows the user to enter data like title, price, page count, and more. The data is then displayed back to the user. The classes inherit from each other to share common attributes and methods for getting and displaying data.

Uploaded by

shahid shahid
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)
38 views3 pages

New Text Document

This C++ program defines classes for publications including book, tape, and disk. It allows the user to enter data like title, price, page count, and more. The data is then displayed back to the user. The classes inherit from each other to share common attributes and methods for getting and displaying data.

Uploaded by

shahid shahid
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/ 3

#include<iostream>

using namespace std;


class Publication{
protected:
string title; //compny title
float price;
public:
Publication(){
price=0;
}
void getdataa(){

cout<<"Enter title of campany ";


cin>>title;
cout<<"Enter price of company ";
cin>>price;
}
void putdataa(){
cout<<"Title of publication is : "<<title<<endl;
cout<<"Price of publication is : "<<price<<endl;
}

};
class Publication_2:public Publication{
int date,month,year;
public:
// void put_data();
// void get_data();
void getdata(){
cout<<"Enter date : ";
cin>>date;
cout<<"Enter month : ";
cin>>month;
cout<<"Enter year : ";
cin>>year;
}
void putdata(){
cout<<" "<<date<<"/"<<month<<"/"<<year<<endl;
}

};
class sale{
protected:
float total_sale[3];
public:
// sale(){
// total_sale[3]={0};
// }
// sale::sale(){

//}
void get_dat(){ //user
for(int a=0;a<3;a++)
{
cout<<"Enter sale amount of month_"<<a+1<<" : ";
cin>>total_sale[a];
}
}

void put_dat(){ //display


for(int a=0;a<3;a++){
cout<<"Sale of month_"<<a+1<<" : "<<total_sale[a]<<endl;
}

};
class book:public Publication_2,public sale{

int count;
public:

void get_data(){ //user


cout<<"Enter Page which you want : ";
cin>>count;
Publication_2::getdata();
}
void put_data(){ //display
cout<<"Page number is : "<<count<<endl;
Publication_2::putdata();
}
};
class tape:public Publication_2,public sale{
// protected:
float minutes;
public:
void get_data(){
cout<<"Enter time in minutes : ";
cin>>minutes;
Publication_2::getdata();
}
void put_data(){
cout<<"Time in minutes is : "<<minutes<<endl;
Publication_2::putdata();
}
};

class disk :public Publication_2,public sale{


private:
enum dtype
{CD,DVD};
dtype userchoice;
public:
void get_dataa(void)
{
char a;
// Publication::getdata();
cout <<endl<<"Enter disk type (c or d) for CD and DVD: ";
cin >> a;
if (a == 'c')
userchoice = CD;
else
userchoice = DVD;

}
void put_dataa()
{
// publication::putdata();
cout << "Disk type is: ";
if (userchoice == CD)
cout << "CD";
else
cout << "DVD";
}
};

int main(){
Publication_2 p;
book b;
tape t;
disk d;
p.getdataa();
b.get_data();
t.get_data();
b.get_dat();
cout<<"||...................Your Entered data is.................||"<<endl;
p.putdataa();
b.put_data();
t.put_data();
b.put_dat();
d.get_dataa();
d.put_dataa();
}

You might also like