title: C++ - ‘_itoa’ was not declared in this scope
body: <p>In the UserProfile.h, I declared the class UserProfile...</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;map&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class UserProfile
  {
     ...
  }
  </code></pre>
  
  <p>then, I defined the function UserProfile() and operator&lt;&lt; in the UserProfile.cpp</p>
  
  <pre><code>#include "UserProfile.h"
  #include &lt;cstdlib&gt;
  
  inline UserProfile::UserProfile()
      : _login("guest"), _user_level(Beginner),
        _times_logged(1), _guesses(0), _correct_guesses(0)
  {
      static int id = 0;
      char buffer[16];
  
      _itoa(id++, buffer, 10);
      _login += buffer;
  }
  ...
  ostream&amp; operator&lt;&lt;(ostream &amp;os, const UserProfile &amp;rhs)
  {
      os &lt;&lt; rhs.login() &lt;&lt; ' '
         &lt;&lt; rhs.level() &lt;&lt; ' '
         &lt;&lt; rhs.login_count() &lt;&lt; ' '
         &lt;&lt; rhs.guess_count() &lt;&lt; ' '
         &lt;&lt; rhs.guess_correct() &lt;&lt; ' '
         &lt;&lt; rhs.guess_average() &lt;&lt; endl;
      return os;
  }
  </code></pre>
  
  <p>However, when I try to compile them, the g++ report error:</p>
  
  <pre><code>g++ UserProfile.cpp E44.cpp -o main
  UserProfile.cpp: In constructor ‘UserProfile::UserProfile()’:
  UserProfile.cpp:11:27: error: ‘_itoa’ was not declared in this scope
       _itoa(id++, buffer, 10);
  </code></pre>
  
  <p>But I have included "cstdlib"... so strange...</p>
  
  <p>Also, when I want to use &lt;&lt; in my main cpp, the g++ report error too:</p>
  
  <pre><code>#include "UserProfile.h"
  
  int main()
  {
      UserProfile anon;
      cout &lt;&lt; anon;
      ...
  }
  </code></pre>
  
  <p>g++ report:</p>
  
  <pre><code>E44.cpp: In function ‘int main()’:
  
  
  E44.cpp:6:10: error: no match for ‘operator&lt;&lt;’ (operand types are ‘std::ostream {aka std::basic_ostream&lt;char&gt;}’ and ‘UserProfile’)
      cout &lt;&lt; anon;
  </code></pre>
  
  <p>I am so confused... Did I do something wrong??</p>