C++ define class member struct and return it in a member function

前端 未结 4 990
南笙
南笙 2020-12-28 22:35

My goal is a class like:

class UserInformation
{
public:
    userInfo getInfo(int userId);
private:
    struct userInfo
    {
        int repu, quesCount, an         


        
4条回答
  •  一生所求
    2020-12-28 23:04

    If the member function is public, then the return type must be publicly visible! Therefore, move the inner struct definition into the public section.

    Note also that it must be defined before the function that uses it.

提交回复
热议问题