'cout'未在此范围中声明 [英] 'cout' was not declared in this scope
本文介绍了'cout'未在此范围中声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个C ++程序:
I have a C++ program:
#include<iostream>
int main()
{
char t = 'f';
char *t1;
char **t2;
cout<<t; //this causes an error, cout was not declared in this scope
return 0;
}
g ++ test.cpp
g++ test.cpp
我收到错误错误:'cout'未在此范围内声明
为什么? p>
why?
推荐答案
将 int main()
:
using namespace std;
您将能够使用 cout
例如:
#include<iostream>
using namespace std;
int main(){
char t = 'f';
char *t1;
char **t2;
cout<<t;
return 0;
}
现在花点时间阅读cout是什么以及发生了什么这里: http://www.cplusplus.com/reference/iostream/cout/
Now take a moment and read up on what cout is and what is going on here: http://www.cplusplus.com/reference/iostream/cout/
这篇关于'cout'未在此范围中声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文