error: `cout' was not declared in this scope
来源:互联网 发布:三体 死神永生 知乎 编辑:程序博客网 时间:2024/06/05 02:34
Linux下C++使用GCC编译出错:
程序:
#include<iostream>
int main()
{
cout << "Hello World!" << endl;
return 0;
}
编译出错:
$ g++ s.cpp -o s.out
s.cpp: In function `int main(int, char**)':
s.cpp:12: error: `cout' was not declared in this scope
s.cpp:12: error: `endl' was not declared in this scope
原因:
C++ 1998 要求cout and endl被调用使用'std::cout'和'std::endl'格式,或using namespace std;
修改后:
#include<iostream>
int main()
{
std::cout <<"Hello World!" << std::endl;
return 0;
或
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "hello world" << endl;
return 0;
}编译通过。
1 0
- error: `cout' was not declared in this scope
- 解决问题 “error: `cout' was not declared in this scope”
- error: `cout' was not declared in this scope
- ‘cout’ was not declared in this scope
- error: '_localtime_not_threadsafe_' was not declared in this scope
- error: ‘exit’ was not declared in this scope
- error: 'UINT64_C' was not declared in this scope
- error: 'memcpy' was not declared in this scope
- error: 'memcpy' was not declared in this scope的解决
- error: ‘BYTE’ was not declared in this scope
- error: ‘closesocket’ was not declared in this scope
- error:inet_addr() was not declared in this scope
- error: ‘exit’ was not declared in this scope 的解决方法
- 关于error: ‘htons’ was not declared in this scope
- error: ‘memcpy’ was not declared in this scope 解决
- error: ‘alarm’ was not declared in this scope 解决
- error: ‘ostream_iterator’ was not declared in this scope
- error: 'glGenFramebuffersOES' was not declared in this scope
- 大小端模式
- shell学习-特殊变量
- (Android studio)关于drawable文件夹的问题
- 八皇后问题
- 枚举enum
- error: `cout' was not declared in this scope
- 各类排序算法总结
- 在eclipse上配置maven
- Spark函数讲解:combineByKey
- JQuery之attr与prop
- 关于在服务器上发布网站遇到的两个问题之解决方案
- NYoj_104最大和
- Android中使用HttpConnection发送中文到服务器端乱码解决办法
- 转转 iOS多线程的初步研究