头一次接触C++,尝试输出一些东西时报错。代码如下:
#include <iostream>
int main(int argc, char** argv) {
cout <<3.4 <<endl;
return 0;
}
报错为:
[Error] ‘cout’ was not declared in this scope
也就是说,输入输出关键字没有被声明。
返回头文件iostream中查看后发现有一个像函数一样的东西,代码如下:
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
{
extern istream cin; /// Linked to standard input
extern ostream cout; /// Linked to standard output
extern ostream cerr; /// Linked to standard error (unbuffered)
extern ostream clog; /// Linked to standard error (buffered)
#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin; /// Linked to standard input
extern wostream wcout; /// Linked to standard output
extern wostream wcerr; /// Linked to standard error (unbuffered)
extern wostream wclog; /// Linked to standard error (buffered)
#endif
}
static i