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

Question2 2

The document defines two classes - book and tape - that inherit properties from publication and sales parent classes. The publication class stores a title and price, while sales tracks monthly sales. Both book and tape classes can get and display this shared data, as well as collect additional attributes like number of pages or length of time. The main function demonstrates collecting data from both a book and tape object, and then displaying it.

Uploaded by

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

Question2 2

The document defines two classes - book and tape - that inherit properties from publication and sales parent classes. The publication class stores a title and price, while sales tracks monthly sales. Both book and tape classes can get and display this shared data, as well as collect additional attributes like number of pages or length of time. The main function demonstrates collecting data from both a book and tape object, and then displaying it.

Uploaded by

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

# include<iostream.

h>

# include<conio.h>

class publication

char title[30];

float price;

public:

void getdata()

cout<<"Enter the title : "; cin>>title;

cout<<"Enter the price : "; cin>>price;

void putdata()

cout<<"The title is : "<<title<<endl;

cout<<"Price is : "<<price<<endl;

};

class sales

float s1,s2,s3; // getting the sale of last three momths

public:

void getdata()

cout<<"Enter the sale of first month:";

cin>>s1;

cout<<"Enter the sale of second month:";

cin>>s2;

cout<<"Enter the sale of third month:";

cin>>s3;

void putdata()

{
cout<<"Sale in first month : $"<<s1<<endl;

cout<<"Sale in sec. month : $"<<s2<<endl;

cout<<"Sale in third month : $"<<s3<<endl;

};

class book: private publication, private sales

int pages;

public:

void getdata()

cout<<" BOOK DETAILS";

publication::getdata();

sales::getdata();

cout<<"Enter the number of pages";

cin>>pages;

void putdata()

cout<<" BOOK DETAILS";

publication::putdata();

cout<<"Number of pages : " <<pages<<endl;

sales::putdata();

};

class tape: private publication,private sales

float time;

public:

void getdata()

cout<<" TAPE DETAILS";

publication::getdata();

sales::getdata();
cout<<"Enter the time length of the casette"; cin>>time;

void putdata()

cout<<" TAPE DETAILS ";

publication::putdata();

cout<<"Time length :"<< time<<endl;

sales::putdata();

};

void main()

book b;

tape t;

clrscr();

b.getdata();

t.getdata();

b.putdata();

t.putdata();

Output –

You might also like