50 ! нужно исправить программу перегрузки оператора = #include #include using namespace std; struct vector2 { int x, y, z; vector2() {} vector2(int x, int y, int z): x(x), y(y), z(z) {} vector2 operator = ( const vector2 & v2) { return vector2(this-> x=v2.x,this-> y=v2.y,this-> z=0); } std: : string tostring() { std: : stringstream s; s < < "(" < < this-> x < < "," < < this-> y < < "," < < this-> z < < ")"; return s.str(); } }; int main2() { vector2 v2(4, 5 ,6); vector2 v3; v3=v2; cout < < v3.tostring(); }
Vector2 &operator=(const Vector2 &v2)
{
this->x = v2.x, this->y = v2.y, this->z = v2.z;
return *this;
}