面试题答案
一键面试class MyVector {
public:
double x;
double y;
MyVector(double _x = 0, double _y = 0) : x(_x), y(_y) {}
MyVector operator+(const MyVector& other) const {
return MyVector(x + other.x, y + other.y);
}
};
class MyVector {
public:
double x;
double y;
MyVector(double _x = 0, double _y = 0) : x(_x), y(_y) {}
MyVector operator+(const MyVector& other) const {
return MyVector(x + other.x, y + other.y);
}
};