forked from natto1784/ooplab
74 lines
1.1 KiB
C++
74 lines
1.1 KiB
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
class Work {
|
|
private:
|
|
char title[50];
|
|
uint price;
|
|
|
|
public:
|
|
void getData();
|
|
void putData();
|
|
};
|
|
|
|
void Work::getData() {
|
|
cout << "Title of publication: ";
|
|
cin >> title;
|
|
cout << "Price of publication: ";
|
|
cin >> price;
|
|
}
|
|
|
|
void Work::putData() {
|
|
cout << "Title of publication: " << title << endl
|
|
<< "Price of publication: " << price << endl;
|
|
}
|
|
|
|
class Book : public Work {
|
|
private:
|
|
uint pageCount;
|
|
|
|
public:
|
|
void getData();
|
|
void putData();
|
|
};
|
|
|
|
void Book::getData() {
|
|
Work::getData();
|
|
cout << "Number of pages: ";
|
|
cin >> pageCount;
|
|
}
|
|
|
|
void Book::putData() {
|
|
Work::putData();
|
|
cout << "Number of pages: " << pageCount << endl;
|
|
}
|
|
|
|
class Tape : public Work {
|
|
private:
|
|
uint lengthMin;
|
|
|
|
public:
|
|
void getData();
|
|
void putData();
|
|
};
|
|
|
|
void Tape::getData() {
|
|
Work::getData();
|
|
cout << "Length in minutes: ";
|
|
cin >> lengthMin;
|
|
}
|
|
|
|
void Tape::putData() {
|
|
Work::putData();
|
|
cout << "Length in minutes: " << lengthMin << endl;
|
|
}
|
|
|
|
int main() {
|
|
Tape t;
|
|
Book b;
|
|
t.getData();
|
|
t.putData();
|
|
b.getData();
|
|
b.putData();
|
|
}
|