Reputation: 17
I don't know what is causing this, but i think it has something to do with the function "password_checker" ??
here is my code :
#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;
string password_checker();
int main()
{
string password;
cout << "please enter your password: " << endl;
cin >> password;
if (password == password_checker)
{
cout << "Access granted" << endl;
}
else if (password == password_checker)
{
cout << "Access denied" << endl;
}
Sleep(15000);
return 0;
}
string password_checker()
{
string password = "123456";
return password;
}
Upvotes: 0
Views: 8904
Reputation: 1645
Compiler thinks, that in line
if (password == password_checker)
you are trying to see if password variable and password_checker function are the same. You have to call that function: password_checker()
.
Upvotes: 2
Reputation: 15574
You should call the function: password_checker()
.
And in else if
part it should be not equals, !=
, or just else
.
Upvotes: 3
Reputation: 55425
password == password_checker
That's trying to call operator==
on a string and a function pointer. You need to call the function so you get a string:
password == password_checker()
Upvotes: 4