#include <iostream>                                                                                                                                                                                                                                                               
#include <string>
using namespace std;
//class Engine

class Car;
class Engine
{
    private:
        int CC_;
        string type_;
        int weight_;
        friend void check_engine(Car&);
        friend class Car;
        friend void check_my_engine(void);
    
    public:
        //Engine constructor
        Engine(int c, string t, int w)
            : CC_(c)
            , type_(t)
            , weight_(w)
        {
            cout << "Engine!" << '\t'
                 << "CC: " << c << '\t' 
                 << "Type: " << t << '\t' 
                 << "Weight: " << w << '\n';
        }

        //Engine destructor
        ~Engine()
        {
            cout << "Engine destructor!" << endl;
        }
};

//class Car - Inheritance class Engine
class Car
{
    private:
        Engine my_engine;   
        friend void check_engine(Car&);
    
    public:
        //Car constructor
        Car(int c, string t, int w)
            : my_engine(c, t, w)
        {
            cout << "Car!" << '\t'
                 << "CC: " << c << '\t'
                 << "Type: " << t << '\t'
                 << "Weight: " << w << endl;
        }

        //function-check_my_engine
        void check_my_engine(void)
        {
            cout << "Check my engine!" << '\t';
            cout << "CC: " << my_engine.CC_ << '\t'
                 << "Type: " << my_engine.type_ << '\t'
                 << "Weight: " << my_engine.weight_ << endl;
        }
                //Car destructor
        ~Car()
        {
            cout << "Car destructor!" << endl;
        }
};

//function-check_engine 
void check_engine(Car& bu)
{
    cout << "Check engine!" << '\t'; 
    cout << "CC: " << bu.my_engine.CC_ << '\t'
         << "Type: " << bu.my_engine.type_ << '\t'
         << "Weight: " << bu.my_engine.weight_ << endl;
}

int main()
{
    Car car(99, "wow", 99);

    check_engine(car);

    check_my_engine(void);  

    return 0;   
}

