C++ 关于and or保留字

版权声明:欢迎转载,不要求署名~~~ https://blog.csdn.net/shadandeajian/article/details/82119384

今天看别人代码,C++用了and,尼玛,那不是pythonjava等高级语言才有的关键字吗,什么时候C++也有了,遂查阅博客,有人说这是C++11的新特性,有人说C++第一开始就有了,遂自己动手。

结论:

不用开-std=c++11也能编译成功,所以这不是C++11的新特性

实验程序:

#include <iostream>
using namespace std;
int main(void) {
    int a = 1, b = 2;
    if (a and b) {
        cout << "IN" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}

编译结果:

g++ -o test test.cpp std=c++98 编译成功

猜你喜欢

转载自blog.csdn.net/shadandeajian/article/details/82119384