A question

I am in an Object Oriented Programming class and we as doing an assignment about overloading operators which I get... But I need to get a "fraction" from the keyboard like 9 12/34 or -4 5/6 My prof told us to use getline and that when he checked our work he would use "valid" fractions * */* form but I can't remember how to read thru the istream and pull the sign/whole number/numerator/denomanator from the istream. Anyone help?
iostream is really nifty in that it can extract different data types on the same line.

If I were to input "Hello world 893 && 53" and used this code on it:

cin>>mystr1>>mynum1>>mystr2>>mynum2;
mystr1 would be filled with "Hello world "
mynum1 would be filled with 893 (the number, not the string)
mystr2 would be filled with " && "
mynum2 would be filled with 53 (the number)

Does that answer your question?
Actually in your example mystr1="Hello".
No mystr1 I think is actually a string. my "str".
Topic archived. No new replies allowed.