Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class electronics //класс электроника (родитель 1)
- {
- string name;
- public:
- void Setname(string name1)
- {
- name = name1;
- }
- void Getname()
- {
- cout << "Раздел электроники: " << name << endl;
- }
- };
- class zavodsborki //родитель 2
- {
- string a;
- int c;
- public:
- void SetA(string a1, int c1)
- {
- a = a1;
- c = c1;
- }
- void GetA()
- {
- cout << "Название завода: " << a << endl;
- cout << "Время сборки: " << c << " часов" << endl;
- }
- };
- class komplect :public electronics //класс комплектующие (потомок от родителя 1)
- {
- string b;
- public:
- void SetB(string b1)
- {
- b = b1;
- }
- void GetB()
- {
- cout << "Бренд комплектующих: " << b << endl;
- }
- };
- class computer :public komplect, public zavodsborki //класс компьютер (потомок родителя 2 и потомка родителя 1)
- {
- int d;
- public:
- void SetC(int d1)
- {
- d = d1;
- }
- void GetC()
- {
- cout << "Гарантийный срок: " << d << " лет" << endl;
- }
- };
- class ofcomputer :public computer //класс офисный компьютер
- {
- int p;
- public:
- void SetD(int p1)
- {
- p = p1;
- }
- void GetD()
- {
- cout << "\nОфисный компьютер : \n";
- cout << "Цена: " << p << " рублей" << endl;
- }
- };
- class gmcomputer :public computer //класс игровой компьютер
- {
- int g;
- public:
- void SetG(int g1)
- {
- g = g1;
- }
- void GetG()
- {
- cout << "\nИгровой компьютер : \n";
- cout << "Цена: " << g << " рублей" << endl;
- }
- };
- int main()
- {
- setlocale(LC_ALL, "RUS");
- ofcomputer r;
- r.Setname("компьютерная техника");
- r.SetA("Сборгрант", 5);
- r.SetB("Lenovo");
- r.SetD(43999);
- r.Getname();
- r.GetB();
- r.GetA();
- r.GetD();
- gmcomputer v;
- v.SetG(115999);
- v.GetG();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement