1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
using std::ostream;
using std::cout;
struct coord {
int x, y, z;
coord(){}
coord(int a, int b, int c) : x(a), y(b), z(c) {}
coord &operator = ( const coord& other) {
x = other.x;
y = other.y;
z = other.z;
return *this;
}
friend ostream &operator << (ostream &out, const coord& other) {
out << "( " << other.x << ", " << other.y << ", " << other.z << " )";
return out;
}
};
int main() {
coord mmap(1, 2, 3), omap(7, 8, 9);
cout << mmap << "\n" << omap << '\n';
mmap = omap;
cout << mmap << "\n";
return 0;
}
|