-1

How override operator+ in first class to second class. I found more information about this but it does not work. Please help me

virtual Array& operator+(const double b) {
        cout << "Добавление числа 10: ";
        Array& x(*this);
        for (int i = 0; i < size; i++) {

        }
        cout << x << endl;
        return x;
    }

virtual ArrayComplex& operator+(const double b) {
        cout << "Добавление числа 1011111111111: ";
        ArrayComplex& x(*this);
        for (int i = 0; i < size; i++) {
            x[i] += 10;
        }
        cout << x << endl;
        return *this;
    }
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88

1 Answers1

1

The signature of your base class Array& operator+(const double b) does not match the derived ArrayComplex& operator+(const double b) that's why it does not work. Make sure the return types are the same.

AdvSphere
  • 986
  • 7
  • 15