代码中的最后两个语句有什么问题?
#include <iostream>
using namespace std;
int main()
{
cout << "2 + 4 = " << 2 + 4 << endl;
cout << "2 * 4 = " << 2 * 4 << endl;
cout << "2 | 4 = " << 2 | 4 << endl;
cout << "2 & 4 = " << 2 & 4 << endl;
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决这个问题?
代码中的最后两个语句有什么问题?
运算符优先级.|并且&优先级低于<<,因此cout << "2 & 4 = " << 2 & 4 << endl;被解析为(cout << "2 & 4 = " << 2) & (4 << endl;).
我该怎么做才能解决这个问题?
把括号周围2 | 4和2 & 4.