mardi 26 juin 2018

How can I fix it "Member declaration not found"?

given the following code:

template<class T>
class Point {
    T x;
    T y;
public:
    Point(T x, T y);

    Point(const Point& p);
    ~Point();
    Point& operator=(const Point& p);

    Point& operator+=(const Point& Prhs);
};

template<class T>
Point<T>& Point<T>::operator+=(const Point<T>& Prhs) {//**error1**
    this->x += Prhs.x; //**error2**
    this->y += Prhs.y; //**error3**
    return *this;
}

template<class T>
Point<T> operator+(const Point<T>& Plhs, const Point<T>& Prhs) { 
    return Plhs += Prhs;
}  

I get the following errors:

error1: Member declaration not found

error2: Field 'x' could not be resolved

error3: Field 'y' could not be resolved

I don't understand what is the reason of these errors. How can I fix it?

Aucun commentaire:

Enregistrer un commentaire