// ( r23.C ) // 入出力ストリ−ムの使い方 // #include class Position { int xx,yy ; public: Position( int px,int py ) { xx = px; yy = py; } int& x() { return xx; } int& y() { return yy; } } ; ostream& operator<<( ostream& os, Position& pos ) // 位置の表示用オペレータ { return os << '(' << pos.x() << ',' << pos.y() << ')'; } main() { Position p1(10,2) ; Position p2(5,20) ; cout << p1 << " " << p2 << endl ; } /* [結果] (10,2) (5,20) */