I have to implement for a given class Vector2D with the attributes float x and float y. Implement the operators + and <<.
class Vector2D
{
private:
float x;
float y;
public:
//No Constructor and Deconstructor needed!
}
my Implementation:
Vector2D operator+(Vector2D& vector1)
{
Vector2D vTemp{0F,0F};
vTemp.x = x + vector1.x;
vTemp.y = y + vector1.y;
return vTemp;
}
std::ostream& operator<<(std::ostream& ost, Vector2D vector1)
{
ost << vector1.x << " " << vector1.y << std::endl;
return ost;
}
So i just wanted to know if my implementation is correct? Thank you