C++ “无操作员”==&引用;匹配这些操作数
我不知道是什么原因造成的,但我认为这和 “密码检查”功能 这是我的密码:C++ “无操作员”==&引用;匹配这些操作数,c++,operands,C++,Operands,我不知道是什么原因造成的,但我认为这和 “密码检查”功能 这是我的密码: #include <iostream> #include <Windows.h> #include <string> using namespace std; string password_checker(); int main() { string password; cout << "please enter your password: " << e
#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;
}
#包括
#包括
#包括
使用名称空间std;
字符串密码检查程序();
int main()
{
字符串密码;
密码;
如果(密码==密码检查程序)
{
库特
这是试图对字符串和函数指针调用运算符==
。您需要调用该函数才能得到字符串:
password == password_checker()
您应该调用函数:password\u checker()
在else中,如果部分不应该等于,!=
,或者只是else
,编译器认为,这是一致的
if(密码==密码检查器)
您正在尝试查看密码变量和密码检查器函数是否相同。必须调用该函数:password\u checker()
password == password_checker()