错误原因
将“const xxx”作为“this”参数传递会丢弃限定符
当函数参数为const的对象,需要给函数添加限定符const,使函数不改变该对象内容。
修改前
class UserProfile{
public:
enum ulevel{
base,middle,high,expert};
UserProfile() = default;
UserProfile(string login,ulevel = base);
bool operator!=(const UserProfile& rhs);
bool operator==(const UserProfile&);
//错误处
string login() {