【发布时间】:2015-05-26 21:56:25
【问题描述】:
这是代码......
#include <iostream>
int main()
{
cout << "WELCOME TO C++ PROGRAMMING";
return 0;
}
当我去终端并传递命令时..
g++ hello.cpp
它显示...
hello.cpp: In function ‘int main()’:
hello.cpp:4:2: error: ‘cout’ was not declared in this scope
cout << "WELCOME TO C++ PROGRAMMING";
^
hello.cpp:4:2: note: suggested alternative:
In file included from hello.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
那是什么原因呢?我该怎么办?
【问题讨论】:
-
它被称为
std::cout。 -
您的代码显然不会在您的问题中产生错误!请注意,错误中的字符串在您的代码中的任何地方都找不到。
-
So what's the reason? And what should I do?可能会停止阅读 80 年代末或 90 年代初的旧 C++ 书籍。 -
您的代码 still 显然不会在您的问题中产生错误! 请注意,该字符串位于第 5 行,而您的错误表明它在第 4 行。我真的真的不喜欢人们从其他一些代码中发布错误消息。