I have been working on a user database in command prompt. It lets you add a user name and password and also sign in. When I compile it I get the error no match for 'operator==' in. I am not quite exactly sure what is causing the it. Also, I have stored all of it in a class.
My header file is:
#ifndef USER_PSW_H
#define USER_PSW_H
#include <string>
class User_Psw
{
public:
User_Psw();
void addToDatabase();
void getNameIndex();
bool PasswordMatches();
void UserCheck();
protected:
private:
int sizeOfDatabase;
int index;
std::string Usernames;
std::string Password;
std::string username;
std::string password;
};
#endif // USER_PSW_H
The constructor is:
User_Psw::User_Psw()
{
const int SIZE = 100;
index = 0;
sizeOfDatabase = 0;
Usernames[SIZE];
Password[SIZE];
}
The Function with the actual error is:
void User_Psw::getNameIndex()
{
for(int i=0; i < sizeOfDatabase; i++)
{
if (username == Usernames[i])
{
index = i;
}
}
}
With the actual line of code containing the error being if (username == Usernames[i])
I can also add more code snippets if It is required.
That won’t work because you’re accessing
Usernameslike a vector when you actually defined the type asstd::string.You want something like this:
Then you can access it like: