Предмет: Информатика,
автор: iiigor
что нужно написать чтобы вывести v3 на экран
#include
using namespace std;
struct Vector3
{
int x, y, z;
Vector3()
{}
Vector3(int x, int y, int z): x(x), y(y), z(z)
{}
Vector3 operator + (Vector3 v1)
{
return Vector3(this->x+v1.x,this->y+v1.y,this->z+v1.z);
}
};
int main()
{
Vector3 v1(1, 2, 3);
Vector3 v2(4, 5 ,6);
Vector3 v3;
v3 = v1 + v2;
}
Ответы
Автор ответа:
0
#include <iostream>
#include <sstream>
using namespace std;
struct Vector3
{
int x, y, z;
Vector3()
{}
Vector3(int x, int y, int z): x(x), y(y), z(z)
{}
Vector3 operator + (Vector3 v1)
{
return Vector3(this->x+v1.x,this->y+v1.y,this->z+v1.z);
}
std::string ToString()
{
std::stringstream s;
s <<"(" << this->x << "," << this->y <<"," << this->z << ")";
return s.str();
}
};
int main()
{
Vector3 v1(1, 2, 3);
Vector3 v2(4, 5 ,6);
Vector3 v3;
v3 = v1 + v2;
cout << v3.ToString();
}
#include <sstream>
using namespace std;
struct Vector3
{
int x, y, z;
Vector3()
{}
Vector3(int x, int y, int z): x(x), y(y), z(z)
{}
Vector3 operator + (Vector3 v1)
{
return Vector3(this->x+v1.x,this->y+v1.y,this->z+v1.z);
}
std::string ToString()
{
std::stringstream s;
s <<"(" << this->x << "," << this->y <<"," << this->z << ")";
return s.str();
}
};
int main()
{
Vector3 v1(1, 2, 3);
Vector3 v2(4, 5 ,6);
Vector3 v3;
v3 = v1 + v2;
cout << v3.ToString();
}
Похожие вопросы
Предмет: Информатика,
автор: tokpanoveldar2008
Предмет: Английский язык,
автор: Аноним
Предмет: Русский язык,
автор: INMT
Предмет: Литература,
автор: zolojin
Предмет: Химия,
автор: JudeGustin