~cpp
#include <iostream>
using namespace std;
class CVector
{
private:
int x;
int y;
public:
CVector();
CVector(int a, int b);
CVector operator+(CVector a);
void SetValue(int a, int b);
int GetX();
int GetY();
};
ostream & operator<<(ostream &os, CVector &a);
CVector::CVector()
{
x = 0;
y = 0;
}
CVector::CVector(int a, int b)
{
x = a;
y = b;
}
CVector CVector::operator+(CVector a)
{
CVector temp;
temp.SetValue(x + a.GetX(), y + a.GetY());
return temp;
}
void CVector::SetValue(int a, int b)
{
x = a;
y = b;
}
int CVector::GetX()
{
return x;
}
int CVector::GetY()
{
return y;
}
ostream & operator<<(ostream & os, CVector &a)
{
os << "x: " << a.GetX() << " y: " << a.GetY() << endl;
return os;
}
int main()
{
CVector v1(50, 100);
CVector v2(22, 33);
CVector v3 = v1.operator +(v2);
cout << "--v1값--" << endl;
cout << v1 << endl;
cout << "--v2값--" << endl;
cout << v2 << endl;
cout << "--v3값--" << endl;
cout << v3 << endl;
return 0;
}