Aufgaben-Python/courses/cpp/08_operator_overloading/musterloesung.cpp

16 lines
No EOL
338 B
C++

#include <iostream>
class Vektor2D {
public:
double x, y;
Vektor2D(double x = 0, double y = 0) : x(x), y(y) {}
Vektor2D operator+(const Vektor2D& other) const {
return Vektor2D(x + other.x, y + other.y);
}
bool operator==(const Vektor2D& other) const {
return x == other.x && y == other.y;
}
};