Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem w/ ADT's and istream / ostream

Status
Not open for further replies.

Bullfrog1870

Technical User
Dec 26, 2005
15
US
I'm trying to work on the "Fractions" implementation in C++. I've been given the header as follows but can't figure out how to implement the functions for getFract / putFract. The user would type "1 2" to represent 1/2. Can someone help? Thanks!


....excerpt from fraction.h
/******************* I/O *********************************/
static int getFract(istream &infile, Fraction &f);
/* returns 1 if a valid fraction is read
0 if an invalid fraction is read
EOF if end of file is detected
*/
static void putFract(ostream &outfile, const Fraction &f );

 
If you were just supposed to read in two numbers from the user with cin, how would you do it?
 
In spirit of C++ language better try to implement:
Code:
istream& operator >>(istream&,Fraction&) /*throw(...)?*/;
ostream& operator <<(ostream&,const Fraction&);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top