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

Surgery

Books past

Uploaded by

jiaaziz232
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)
8 views3 pages

Surgery

Books past

Uploaded by

jiaaziz232
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

//publication class and derived classes

#include<iostream>

#include<string>

using namespace std;

///////////////////////////////////////////////////////

class publication // base class

private:

string title;

float price;

public:

void getdata()

cout<<"\nEnter title; "<<endl;

cin>>title;

cout<<"\nEnter price; "<<endl;

cin>>price;

void putdata() const

cout<<"\nEnter title; "<< title;

cout<<"\nEnter price; "<< price;

};

//////////////////////////////////////////////////////

class book : private publication //derived class

private:

int pages;
public:

void getdata()

publication::getdata();

cout<<"enter no of pages; "<<endl;

cin>>pages;

void putdata() const

publication::putdata();

cout<<"\nPages; "<< pages;

};

//////////////////////////////////////////////////////

class tape : private publication //derived class

private:

float time;

public:

void getdata()

publication::getdata();

cout<<"entre playing time; "<<endl;

cin>>time;

void putdata() const

publication::putdata();

cout<<"\nPlaying time; "<< time;


}

};

/////////////////////////////////////////////////////

int main()

book fantasybook1; // defining the publications

tape tape1;

fantasybook1.getdata(); // getting data for publications

tape1.getdata();

fantasybook1.putdata(); // displaying publications data

tape1.putdata();

cout<< endl;

return 0;

OUTPUT:

You might also like