/* ECP: FILEname=fig14_28.cpp */ /* 1*/ // Base class shape. /* 2*/ class Shape /* 3*/ { /* 4*/ protected: /* 5*/ const char *Name; // Shape identifier. /* 6*/ public: /* 7*/ Shape( ) { } // Constructor. /* 8*/ virtual double Area( ) const = 0; // Area function. /* 9*/ int operator < ( const Shape & Rhs ) const // < /*10*/ { return Area( ) < Rhs.Area( ); } /*11*/ friend ostream & operator << // Output. /*12*/ ( ostream & Output, const Shape & S ); /*13*/ }; /* 1*/ ostream & operator << ( ostream & Output, const Shape & S ) /* 2*/ { /* 3*/ Output << S.Name << " of area " << S.Area( ) << "\n"; /* 4*/ return Output; /* 5*/ }