It makes sense to make the type of nested structure publicly available, since user code should be able to use it. Also, post the structure declaration before it is first used. Outside the scope of the class, use the scope :: resolution to denote nested types.
class UserInformation { public: struct UserInfo { int repu, quesCount, ansCount; }; public: UserInfo getInfo(int userId); private: UserInfo infoStruct; int date; }; UserInformation::UserInfo UserInformation::getInfo(int userId) { infoStruct.repu = 1000; return infoStruct; }
pic11
source share