title: C++ define class member struct and return it in a member function
body: <p>My goal is a class like:</p>
  
  <pre><code>class UserInformation
  {
  public:
      userInfo getInfo(int userId);
  private:
      struct userInfo
      {
          int repu, quesCount, ansCount;
      };
      userInfo infoStruct;
      int date;
  };
  
  userInfo UserInformation::getInfo(int userId)
  {
      infoStruct.repu = 1000; 
      return infoStruct;
  }
  </code></pre>
  
  <p>but the compiler gives error that in defintion of the public function <code>getInfo(int)</code> the return type <code>userInfo</code> is not a type name.</p>