lundi 1 juin 2020

Operator Overloading as member function

Why is it giving the error.

 class Complex{
    int real,imaginary;
    public:
    Complex():real(0),imaginary(0){};
    Complex(int real, int imaginary):real(real),imaginary(imaginary){};
    int getreal()const{return real;}

    int getimaginary()const{return imaginary;};
    Complex &operator=(const Complex& );
    Complex operator*(){
      return Complex(real,-imaginary);
    }
    Complex  operator+(const Complex &a, const Complex &d){

      return  Complex (d.getreal()+a.getreal(),a.getimaginary()+d.getimaginary());
    }


  };

When trying to overload the assingment operator. Eroor says: too many parameter

What operators can we overload as member function and what not

Aucun commentaire:

Enregistrer un commentaire