无法使用迭代器查找类对象。 (二进制“ ==”:“ userInfo”未定义此运算符)

我对C ++相当陌生,尤其是在将迭代器与类向量一起使用时。

我正在尝试创建一个函数,该函数将通过搜索包含所有类对象(用户)的向量并将其与输入匹配来验证登录时的用户名/密码。但是,我收到此错误:

binary '==': 'userInfo' does not define this operator or a conversion to a type acceptable to the predefined operator

我试图在线查找解决方案,但被告知该错误与迭代器使用不当有关。这是我的功能代码:

void userInfo::VerifyUser()
{
    std::string tempusername = get_input < std::string >("CONSOLE: Please insert your username");
    std::vector<userInfo>::iterator user = std::find(m_allUsers.begin(), m_allUsers.end(), [&tempusername](userInfo& profile) {return profile.get_username() == tempusername; });
    {
        if (user != m_allUsers.end())
        {
            int choice = get_input<int>("CONSOLE: Username already exists - 0 to login and 1 to register");
            if (choice == 0)
            {
                std::string temppassword = get_input < std::string >("CONSOLE: Please insert your password to login");
                std::vector<userInfo>::iterator pass = std::find(m_allUsers.begin(), m_allUsers.end(), [&tempusername]( userInfo& profile) {return profile.get_username() == tempusername; });
                if (pass != m_allUsers.end())
                {
                    while (!(VerifyPassword(tempusername, temppassword)))
                    {
                        std::string temppassword = get_input < std::string >("CONSOLE: Please insert your password to login");
                        std::vector<userInfo>::iterator pass = std::find(m_allUsers.begin(), m_allUsers.end(), [&tempusername](userInfo& profile) {return profile.get_password() == tempusername; });
                    }

                    std::cout << "SUCESS: You have entered the correct information - logging you in." << std::endl;
                    userInfo profile(tempusername, temppassword, 1, 0);
                }
            }
            else if (choice == 1)
            {
                VerifyUser();
            }
        }
        else
        {
            std::cout << "CONSOLE: Username does not exist in the database - redirecting to registeration menu." << std::endl;
            userInfo().register_user();
        }
    }
}

bool userInfo::VerifyPassword(std::string username, std::string password)
{
    std::string tempuser;
    std::string temppass;
    std::string file_name = username + ".txt";
    std::fstream file(file_name);
    while (!file.eof())
    {
        file >> tempuser;
        file >> temppass;
    }
    if (temppass == password)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}