Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.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++_Logical Operators - Fatal编程技术网

C++ 错误代码应为(';)';发生在逻辑运算符上

C++ 错误代码应为(';)';发生在逻辑运算符上,c++,logical-operators,C++,Logical Operators,这个错误代码只是突然出现,以前从未发生过。它在所有逻辑运算符(and、or)的下面都有一个红色的行,并且显示了预期的错误('),但代码运行良好。有人知道为什么会这样吗 下面是示例代码 while (item_list[index].title != item and index != last + 1) //error occurs here underlines red at the and operator { ++index; } if (i

这个错误代码只是突然出现,以前从未发生过。它在所有逻辑运算符(and、or)的下面都有一个红色的行,并且显示了预期的错误('),但代码运行良好。有人知道为什么会这样吗

下面是示例代码

    while (item_list[index].title != item and index != last + 1) //error occurs here underlines red at the and operator
    {
        ++index;
    }
    if (index != last + 1)
    {
        cout << "Item is found at row " << index + 1 << "\n";
    }
    else
    {
        cout << "Item is not found in the table"
             << "\n";
    }
while(item_list[index].title!=item and index!=last+1)//此处出现错误,在and运算符处加上红色下划线
{
++指数;
}
如果(索引!=last+1)
{

cout问题在于以下几行:

while (item_list[index].title != item and index != last + 1)

更改“and & &,没有操作符调用,C++中只有& &和……/P>这是一个很好的了解”。请复制粘贴编译错误。2)“它有一个红色的线”,所以它是一个智能错误,还是一个编译错误?3)“代码运行良好”。如果代码没有编译,它就不会运行。IDE有时会感到困惑,我甚至可以想象你的代码不知道

(这并不常见)。重要的是编译器对代码所做的操作听起来好像您的IDE不喜欢
,并且期望
&
,而您使用的编译器对它没有问题。无论问题的原因如何,我建议您使用
&
而不是
。这是通常的做法。