three_d() { x = у = z = 0; }
three_d(int i, int j, int k) { x = i; у = j; z = k; }
friend three_d operator+(three_d op1, three_d op2);
three_d operator= (three_d op2); // Операнд op1 передается неявно.
void show();
};
// Теперь это функция-"друг".
three_d operator+(three_d op1, three_d op2)
{
three_d temp;
temp.x = op1.x + op2.x;
temp.у = op1.у + op2.y;
temp.z = op1.z + op2.z;
return temp;
}
// Перегрузка присваивания.
three_d three_d::operator=(three_d op2)
{
x = op2.x;
у = op2.у;
z = op2.z;
return *this;
}
// Отображение координат X, Y, Z.
void three_d::show()
{
cout << x << ", ";
cout << у << ", ";
cout << z << "\n";
}