using namespace std;
template <typename A>
class vector3d_add
{
    public:
            vector3d_add(A x, A y, A z);
            virtual ~vector3d_add();
            void setX(A x);
            void setY(A y);
            void setZ(A z);
            void display();
                  A getX();
                  A getY();
                  A getZ();
            A operator+ (const A& v2);
            A& operator+= (const A& v2);
    private:
             A x;
             A y;
             A z;
};
template <typename A>
vector3d_add<A>::~vector3d_add()
{
    cout << "deleted" << endl;
}
template <typename A>
vector3d_add<A>::vector3d_add(A x, A y, A z)
{
    this->x = x;
    this->y = y;
    this->z = z;
}
template <typename A>
A& operator+=(const A& v2) //x1
{
    this->x += v2.x;
    this->y += v2.y;
    this->z += v2.z;
    return *this;
}
template <typename A>
A operator+(const A& v2)
{
    return A(*this) += v2; //x2
}
template <typename A>
void vector3d_add<A>::display()
{
    cout<<this->x<<endl<<this->y<<endl<<this->z<<endl;
}
int main()
{
    VECTOR<int>v1(10,10,10);
    VECTOR<int>v2(10,10,10);
    VECTOR<int>v3=v2+v1;
    v3.display();
}
I want to realize a code, that can add 3D vector with template and operator overloading (+operator and +=operator MUST BE USED). I don't know how to get any further.
I searched at the internet for other solution, but nodody was using the +operator AND the +=operator.
I tried other things, to realize it, but i dont get it.
ERORRS:
x1->'A& operator+=(const A&)' must take exactly two arguments
x2->invalid use of 'this' in non-member function
 
     
    