/* ECP: FILEname=fig14_31.cpp */ /* 1*/ // Read a pointer to a shape. /* 2*/ // Bare bones, with no error checking. /* 3*/ istream & operator >> ( istream & Input, Shape * & S ) /* 4*/ { /* 5*/ char Ch; /* 6*/ double D1, D2; /* 7*/ Input >> Ch; // First character represents shape. /* 8*/ switch( Ch ) /* 9*/ { /*10*/ case 'c': /*11*/ Input >> D1; /*12*/ S = new Circle( D1 ); /*13*/ break; /*14*/ case 'r': /*15*/ Input >> D1 >> D2; /*16*/ S = new Rectangle( D1, D2 ); /*17*/ break; /*18*/ case 's': /*19*/ Input >> D1; /*20*/ S = new Square( D1 ); /*21*/ break; /*22*/ default: /*23*/ cerr << "Needed one of c, r, or s" << endl; /*24*/ S = new Circle; // Radius is 0. /*25*/ break; /*26*/ } /*27*/ return Input; /*28*/ }