Advertisement
MARSHAL327

Untitled

Jan 26th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //==============
  5. // КЛАСС Device
  6. //==============
  7. class Device {
  8. private:
  9.     string name, manufacturer;
  10.     int power;
  11. public:
  12.     Device();
  13.     void Device_input();
  14.     void Device_print();
  15. };
  16.  
  17. // методы
  18. Device::Device() {
  19.     power = 0;
  20. }
  21.  
  22. void Device::Device_input() {
  23.     cout << "Введите имя:" << endl;
  24.     cin >> name;
  25.     cout << "Введите производителя:" << endl;
  26.     cin >> manufacturer;
  27.     cout << "Введите мощность:" << endl;
  28.     cin >> power;
  29. }
  30.  
  31. void Device::Device_print() {
  32.     cout << "name = " << name << endl;
  33.     cout << "manufacturer = " << manufacturer << endl;
  34.     cout << "power = " << power << endl;
  35. }
  36.  
  37. //==============
  38. //==============
  39. //==============
  40.  
  41. class Sound {
  42. private:
  43.     int volume, frequency;
  44. public:
  45.     Sound();
  46.     void Sound_input();
  47.     void Sound_print();
  48. };
  49.  
  50. // методы
  51. Sound::Sound() {
  52.     volume = frequency = 0;
  53. }
  54.  
  55. void Sound::Sound_input() {
  56.     cout << "Введите громкость:" << endl;
  57.     cin >> volume;
  58.     cout << "Введите частоту:" << endl;
  59.     cin >>  frequency;
  60. }
  61.  
  62. void Sound::Sound_print() {
  63.     cout << "volume = " << volume << endl;
  64.     cout << "frequency = " << frequency << endl;
  65. }
  66.  
  67. class Siren : public Device, public Sound {};
  68.  
  69. int main()
  70. {
  71.     Siren S;
  72.     S.Device_input();
  73.     S.Sound_input();
  74.     S.Device_print();
  75.     S.Sound_print();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement