//overloading operators #include class 3_d { int x, y, z; //coordinates public: 3_d operator+( 3_d t ); void show( void ); void assign( int mx, int my, int mz ); }; //overload the + 3_d 3_d::operator+( 3_d t ) { 3_d temp; temp.x = x+t.x; temp.y = y+t.y; temp.z = z+t.z; return temp; } //show x, y, z coord. void 3_d::show( void ) { cout << x << ","; cout << y << ","; cout << z << "\n"; } void 3_d::assign( int mx, int my, int mz ) { x = mx; y = my; z = mz; } //========================================== main( void ) { 3_d a, b, c; a.assign( 1, 2, 3 ); b.assign( 10, 10, 10 ); a.show(); b.show(); c = a+b; c.show(); c = a+b+c; c.show(); return 0; }