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, 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)
{}

你可能感兴趣的:(C++)