title: C++ Input Operator Overloading
body: <p>I'm trying to overload the input operator on a UserLogin class I've created. No compile-time errors are thrown, however the values are not set either.</p>
  
  <p>Everything runs, but it the content of ul remains:
  string id is sally
  Time login is 00:00
  Time logout is 00:00</p>
  
  <p>Entry Point</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "UserLogin.h"
  
  using namespace std;
  
  int main() {
      UserLogin ul;
  
      cout &lt;&lt; ul &lt;&lt; endl; // xxx 00:00 00:00
      cin &gt;&gt; ul; // sally 23:56 00:02
      cout &lt;&lt; ul &lt;&lt; endl; // Should show sally 23:56 00:02
                          // Instead, it shows xxx 00:00 00:00 again
  
      cout &lt;&lt; endl;
      system("PAUSE");
  }
  </code></pre>
  
  <p>UserLogin.h</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "Time.h"
  
  using namespace std;
  
  class UserLogin
  {
      // Operator Overloaders
      friend ostream &amp;operator &lt;&lt;(ostream &amp;output, const UserLogin user);
      friend istream &amp;operator &gt;&gt;(istream &amp;input, const UserLogin &amp;user);
  
      private:
          // Private Data Members
          Time login, logout;
          string id;
  
      public:
          // Public Method Prototypes
          UserLogin() : id("xxx") {};
          UserLogin( string id, Time login, Time logout ) : id(id), login(login), logout(logout) {};
  };
  </code></pre>
  
  <p>UserLogin.cpp</p>
  
  <pre><code>#include "UserLogin.h"
  
  ostream &amp;operator &lt;&lt;( ostream &amp;output, const UserLogin user )
  {
      output &lt;&lt; setfill(' ');
      output &lt;&lt; setw(15) &lt;&lt; left &lt;&lt; user.id &lt;&lt; user.login &lt;&lt; " " &lt;&lt; user.logout;
  
      return output;
  }
  
  istream &amp;operator &gt;&gt;( istream &amp;input, const UserLogin &amp;user )
  {
      input &gt;&gt; ( string ) user.id;
      input &gt;&gt; ( Time ) user.login;
      input &gt;&gt; ( Time ) user.logout;
  
      return input;
  }
  </code></pre>