在使用cenos或者ubantu时,gcc编译报错,可能是缺少标准库导致
解决方法如下
vim test.cpp
在test.cpp中打入代码,如下
#include <iostream>
using namespace std;
int main()
{
cout<<"hello C++"<<endl;
return 0;
}
使用如下c++11
g++ -std=c++11 test.cpp -o main
再运行编译后文件
./main
运行成功