Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ “无操作员”==&引用;匹配这些操作数_C++_Operands - Fatal编程技术网

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()