【发布时间】:2017-11-21 15:00:10
【问题描述】:
我读到 cout 是 ostream 的一个对象...
但是为什么这段代码
#include<ostream>
using namespace std;
int main()
{
cout << "ostream included!" << endl;
return 0;
}
抛出错误:-
practice1.cpp: In function 'int main()':
practice1.cpp:6:1: error: 'cout' was not declared in this scope
cout << "ostream included!" << endl;
^~~~
我的理解有问题还是有其他错误? (MinGW Windows 10)
提前致谢!
【问题讨论】:
-
Cout 在
iostream.h中声明 -
投票结束是一个错字。您的意思是包含
<iostream>而不是<ostream> -
@DigvijaysinhGohil
iostream,而不是iostream.h -
以后你可以参考cppreference网站,它会告诉你
ostream里面有什么。 -
@DigvijaysinhGohil 错误。标准指定的标头仅命名为
iostream,没有扩展名。如果您有一些提供符号链接或其他东西的编译器或库,那是无关紧要的。