home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / CH_12 / 706.jpg < prev    next >
Joint Photographic Experts Group Image  |  2013-12-12  |  555KB  |  2550x3300
Labels: book | crt screen | poster | reckoner | sky
OCR: 706 Chapter Discovering C++ This top -level function needs to access the private data of class Fract ion There- fore we will declare the overload of the operator as friend of the Fracti .on class Example 12-12: fraction.h fracti ion.h Contains the declaration of the Fract ion class Incl lude Files include iostream h> class Fraction Note 1 fri iend ostream& operator >> ostream& str, Fract Lon PRECONDITION: str must be available for output POSTCONDITION: will be written to str. publi C Fracti Lon() num 0 denom 1 PRECOND L ON none POSTCOND :NOILI the obj ect is initiali ized as 0/1. Fracti ion int n int PRECONDITION: none POSTCOND ITION not equal to 0 the oqo ect zed as Othe rwi initialized as int numera tor const return num; PRECONDITION nune POSTCONDITION: value of num returned int denom na ...