2021-06-24 13:43:37 +00:00
|
|
|
#ifndef EXERCISE_2_HPP_
|
|
|
|
#define EXERCISE_2_HPP_
|
|
|
|
|
2021-06-25 12:24:13 +00:00
|
|
|
#include <iostream>
|
2021-06-24 13:43:37 +00:00
|
|
|
|
2021-06-25 12:24:13 +00:00
|
|
|
class Car
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string m_company;
|
|
|
|
std::string m_model;
|
|
|
|
protected:
|
|
|
|
std::string getCompany() const
|
|
|
|
{
|
|
|
|
return m_company;
|
|
|
|
}
|
2021-06-24 13:43:37 +00:00
|
|
|
|
2021-06-25 12:24:13 +00:00
|
|
|
std::string getModel() const
|
|
|
|
{
|
|
|
|
return m_model;
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
Car(std::string company, std::string model) : m_company(company), m_model(model)
|
|
|
|
{
|
|
|
|
std::cout << "Транспортное средство компании " + getCompany() + ", модель " + getModel() << std::endl;
|
|
|
|
}
|
|
|
|
};
|
2021-06-24 13:43:37 +00:00
|
|
|
|
2021-06-25 12:24:13 +00:00
|
|
|
class PassengerCar : virtual public Car
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PassengerCar(std::string company, std::string model) : Car(company, model)
|
|
|
|
{
|
|
|
|
std::cout << "Легковой автомобиль компании " + getCompany() + ", модель " + getModel() << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Bus : virtual public Car
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Bus(std::string company, std::string model) : Car(company, model)
|
|
|
|
{
|
|
|
|
std::cout << "Автобус компании " + getCompany() + ", модель " + getModel() << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Minivan : public PassengerCar, public Bus
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Minivan(std::string company, std::string model) :
|
|
|
|
PassengerCar(company, model), Bus(company, model), Car(company, model)
|
|
|
|
{
|
|
|
|
std::cout << "Минивэн компании " + getCompany() + ", модель " + getModel() << std::endl;
|
|
|
|
}
|
|
|
|
};
|
2021-06-24 13:43:37 +00:00
|
|
|
|
|
|
|
#endif
|