Using overloaded + operator in derived class

I was practicing overloaded assignment operator use from derived class(Airplane in my case), and it worked just fine. Problem i have is with overloaded + operator. It should just sum engine_power and seats from two Airplane objects, and then after sum flying_speed(bolded lines). And it really does go to the Base class overloaded + operator function when called from derived class (Vehicle::operator +(rhs);), but then Vehicle variable temp sums everything as it should do, but for some reason calls destructor right after and my Derived object’s Base class atributes remain 0.Looking forward to any advice or suggestion

#include <iostream>
using namespace std;

class Vehicle {
protected:
    int engine_power;
    int seats;
public:
    Vehicle(int engine_power, int seats)
        : engine_power{engine_power},seats{seats}{
            cout << "Vehicle constructor" << endl;
        }

    Vehicle &operator=(const Vehicle &rhs){
            cout << "Vehicle assignment" << endl;
        if (this==&rhs) 
            return *this;
        else{
            engine_power=rhs.engine_power;
            seats=rhs.seats;
            return *this;
            }
        }
    Vehicle operator+(const Vehicle &rhs){
        Vehicle temp{0,0};
        temp.engine_power=engine_power+rhs.engine_power;
        temp.seats=seats+rhs.seats;
        return temp;
    }
    ~Vehicle() {
        cout << "Vehicle destructor" << endl;
    }
};

class Airplane : public Vehicle {
private:
    int flying_speed;
public:
    Airplane(int a, int b, int flying_speed)
        : Vehicle{a,b}, flying_speed{flying_speed}{
            cout << "Airplane constructor" << endl;
        }

    Airplane &operator= (const Airplane &rhs){
        cout << "Airplane assignment" << endl;
        if (this!=&rhs){
            Vehicle::operator =(rhs);
            flying_speed=rhs.flying_speed;
            return *this;
        } else
            return *this;
    }
    Airplane operator+ (const Airplane &rhs) {
        Airplane temp{0,0,0};
        **Vehicle::operator +(rhs);**
        **temp.flying_speed=flying_speed+rhs.flying_speed;**
        return temp;
    }
    ~Airplane() {
        cout << "Airplane destructor" << endl;
    }
};

int main(){
Airplane a1 {10,20,30};
Airplane a2 {10,22,33};
Airplane a3 = a1+a2;
return 0;
}

Answer

As pointed out in the comments, you don’t store the result of your base class Vehicle::operator+() when called in the derived class. Here is the fixed code:

#include <iostream>
using namespace std;

class Vehicle {
protected:
    int engine_power;
    int seats;
public:
    Vehicle(int engine_power, int seats)
        : engine_power{engine_power},seats{seats}{
            //cout << "Vehicle constructor" << endl;
        }

    Vehicle operator+(const Vehicle &rhs){
        Vehicle temp{0,0};
        temp.engine_power=engine_power+rhs.engine_power;
        temp.seats=seats+rhs.seats;
        return temp;
    }
};

class Airplane : public Vehicle {
private:
    int flying_speed;
public:
    Airplane(int a, int b, int flying_speed)
        : Vehicle{a,b}, flying_speed{flying_speed}{
            //cout << "Airplane constructor" << endl;
        }
    Airplane operator+ (const Airplane &rhs) {
        Airplane temp{0,0,0};
        static_cast<Vehicle&>(temp) = Vehicle::operator +(rhs);
        temp.flying_speed=flying_speed+rhs.flying_speed;
        return temp;
    }
    void print() const {
        cout << " power " << engine_power 
             << " seats " << seats  
             << " speed " << flying_speed 
            << std::endl;
    }
};

int main(){
    Airplane a1 {10,20,30};
    Airplane a2 {10,22,33};
    Airplane a3 = a1+a2;
    a3.print();
    return 0;
}

Output: power 20 seats 42 speed 63

live demo