Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- class Engine
- {
- float eng_volume;
- int power;
- public:
- Engine(float vol, int pow) : eng_volume(vol), power(pow) {}
- void printEng() { cout << "Объём " << eng_volume << "л, мощность " << power << "л.с." << endl; }
- };
- class Body
- {
- int door_cnt;
- string type;
- public:
- Body(int cnt, string tpe) : door_cnt(cnt), type(tpe) {}
- int getDoorCnt() {
- return door_cnt;
- }
- string getType() {
- return type;
- }
- };
- class Color
- {
- string color;
- public:
- Color(string c) : color(c) {}
- string getColor() {
- return color;
- }
- };
- class Car :
- private Engine, private Body, private Color
- {
- string make;
- public:
- Car(string _make, string color, string type, int door_cnt, int power, double eng_vol) :
- Color(color), Engine(eng_vol, power), Body(door_cnt, type), make(_make) {}
- void printInfo() {
- cout << "Автомобиль " << make
- << ", цвет " << getColor() << " "
- << getDoorCnt() << "-дверный " << getType()
- << endl << "Двигатель: " << endl;
- printEng();
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- Car myCar("Ваз 2107", "вишнёвый", "седан", 4, 72, 1.6);
- myCar.printInfo();
- system("pause>>void");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement