#include<iostream>
struct Vertex {
float x, y;
Vertex add(const Vertex& other) const {
return Vertex(x + other.x, y + other.y);
}
Vertex operator+(const Vertex& other)const {
return Vertex(x + other.x, y + other.y);
}
Vertex Multiply(const Vertex& other)const {
return Vertex(x * other.x, y * other.y);
}
Vertex operator*(const Vertex& other)const {
return Vertex(x * other.x, y * other.y);
}
bool operator==(const Vertex& other)const {
return (x == other.x) && (y == other.y);
}
};
std::ostream& operator<<(std::ostream& stream, const Vertex& vertex) {
stream << vertex.x << ", " << vertex.y;
return stream;
}
int main() {
Vertex speed(0.5f, 0.5f);
Vertex position( 1.f,-1.f );
Vertex powerup( 3.f,3.f );
Vertex result1 = position.add(speed.Multiply(powerup));
std::cout << result1 << std::endl;
Vertex result2 = position + speed * powerup;
std::cout << result2 << std::endl;
std::cout << (result1 == result2) << std::endl;
}