Overwriting the >> operator for derived classes
<p>I have a program I am working on that requires us to overload the >> for the Employee class so that when it's used it reads in the right type of employee so I have something like this in my main program:</p>

<pre><code> Employee *emp;
 empIn &gt;&gt; emp;
</code></pre>

<p>I figured the base class is where I would want to do it, because it is the only one that applies to all of the derived classes.  The type is determined by an integer at the start of the line so I figured that something like this might work (as I don't know the type until I read it):</p>

<pre><code>istream &amp;operator &gt;&gt; (istream &amp;stream, Employee &amp;emp)
{
   int type;
   stream &gt;&gt; type;
   switch(type){
      case 1:
         *emp = new Hourly;
         break;
           ...
   }
   return stream;
}
</code></pre>

<p>But, it doesn't work.  I'm I going about this the right way?  And if not, please point me in the right direction.</p>
