想要用std::cout输出流来输出一个vector,必须要重载 << 运算符
std::ostream& operator << (std::ostream& stream,const Vector2& other)//这里通过引用用来传递vector变量
{
stream << other.x <<" ,"<<other.y;
//最后要返回一个对流的引用!
return stream;
}
想要用std::cout输出流来输出一个vector,必须要重载 << 运算符
std::ostream& operator << (std::ostream& stream,const Vector2& other)//这里通过引用用来传递vector变量
{
stream << other.x <<" ,"<<other.y;
//最后要返回一个对流的引用!
return stream;
}