using peek() in overloading an input stream
<p>I'm working on overloading >> for a fraction class and there are a few different types of input that need to be handled.  Examples: 1/2 (regular fraction), 2+3/4 (mixed number), 2 (whole number).  The professor provided a hint below saying that we need to use the peek() function in order to figure out what the second character is after the integer.  So what that means is that <code>temp</code> needs to be declared as an int right?  My question is that if temp is an int, how do you get the rest of the fraction (when it's not a whole number)?</p>

<p>Based on my experience, I would declare temp as a string instead and not use peek.  But the int and peek approach must have some merit since the prof suggested it.</p>

<pre><code>in &gt;&gt; temp;
if (in.peek() == '+'){
    doSomething...
} else if (in.peek() == '/'){
    doSomethingElse...
} else {
    doThirdOption
}
</code></pre>
