C++ 第四章 习题4.3踩坑

1

UserProfile\main.cpp|9|undefined reference to `UserProfile::levelabi:cxx11 const’|

将>>和<<运算符重载放在UserProfile.cpp里,在main.cpp申明重载即可

main.cpp
ostream& operator<<( ostream &os, const UserProfile &rhs );
istream& operator>>( istream &is, UserProfile &rhs );

2

UserProfile\main.cpp|21|undefined reference to `UserProfile::UserProfile(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, UserProfile::uLevel)’|

将构造函数放在UserProfile.h

class{
    
    };
inline UserProfile::UserProfile(string login,uLevel level)
    :_login(login),_user_level(level),_times_logged(1),_guesses(0),_correct_guesses(0)
{
    
    }

猜你喜欢

转载自blog.csdn.net/weixin_43387612/article/details/107441743