Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //==============
- // КЛАСС Device
- //==============
- class Device {
- private:
- string name, manufacturer;
- int power;
- public:
- Device();
- void Device_input();
- void Device_print();
- };
- // методы
- Device::Device() {
- power = 0;
- }
- void Device::Device_input() {
- cout << "Введите имя:" << endl;
- cin >> name;
- cout << "Введите производителя:" << endl;
- cin >> manufacturer;
- cout << "Введите мощность:" << endl;
- cin >> power;
- }
- void Device::Device_print() {
- cout << "name = " << name << endl;
- cout << "manufacturer = " << manufacturer << endl;
- cout << "power = " << power << endl;
- }
- //==============
- //==============
- //==============
- class Sound {
- private:
- int volume, frequency;
- public:
- Sound();
- void Sound_input();
- void Sound_print();
- };
- // методы
- Sound::Sound() {
- volume = frequency = 0;
- }
- void Sound::Sound_input() {
- cout << "Введите громкость:" << endl;
- cin >> volume;
- cout << "Введите частоту:" << endl;
- cin >> frequency;
- }
- void Sound::Sound_print() {
- cout << "volume = " << volume << endl;
- cout << "frequency = " << frequency << endl;
- }
- class Siren : public Device, public Sound {};
- int main()
- {
- Siren S;
- S.Device_input();
- S.Sound_input();
- S.Device_print();
- S.Sound_print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement