73
lab5/13.cpp
Normal file
73
lab5/13.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#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();
|
||||
}
|
Reference in New Issue
Block a user