【问题标题】:no operator "&&" matches these operands [closed]没有运算符 \"&&\" 匹配这些操作数[关闭]
【发布时间】:2023-01-27 17:33:23
【问题描述】:
#include <iostream>
#include <fstream>
#include <cstring>
#include <stdlib.h>
using namespace std;

while (input >> ID >> pass)
{
    if (ID == userID && pass = password)
    {
        count = 1;
        system("cls");
    }

为什么这行不通?

我正在尝试查找 ID 和 pass 的记录,但 && 没有运算符?

【问题讨论】:

  • ===...

标签: c++ operators


【解决方案1】:

我的回答假设有问题的代码驻留在 main 函数中并且变量设置正确。我在问题中看不到这一点。

在这种情况下,这条线

  if (ID == userID && pass = password)

应该

  if (ID == userID && pass == password)

一个 = 是一个赋值,而 == 是一个比较。

【讨论】:

    猜你喜欢
    • 2015-09-13
    • 2013-04-09
    • 2013-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多