错误:cout 未声明,并且给我带来了编译问题
error: cout was not declared and is giving me compiling problems
#include <ostream>
#include <string>
using namespace std;
int main()
{
char c = 'x';
int i1 = c;
int i2 = 'x';
char c2 = i1;
cout << c << ' << i1 << ' << c2 << 'n';
}
我不断收到错误:"cout"未在此范围内声明。警告:字符常量对于其类型来说太长(默认情况下启用(
你需要
#include <iostream>
这就是定义std::cout
的地方。 (而且你不需要#include <ostream>
。
您有一个语法错误,其中:
cout << c << ' << i1 << ' << c2 << 'n';
您有这些单引号,导致您连续两次传递 <<运算符。
另外,使用
#include <iostream>
std::cout 在 中定义。尝试将包含从 更改为 。
此外,如果您希望<<i1 <<'应该用双引号引起来。
相关文章:
- GTK C++:找不到信号处理程序 您是否使用 -rdynamic 进行了编译?
- 全局变量在 C++ 中是否显着提高了编译速度?
- 这是通过初始化 constexpr 变量来标记编译错误的合理跳转
- GTK+3 编译错误"找不到信号处理程序",您是否使用 -rdynamic 进行了编译?
- Cmake Mac OSX库链接问题:在Linux上进行编译,但在Mac上进行了编译
- 怎么来了?在特征中未检测到别名
- 发送输入发送"num8"当我想发送"vk_up"?怎么来了?
- 静态内存中的数组的大小可以在运行时更改C++?怎么来了
- 我能够调用一个不带在 c++ 中传递所需参数的方法.怎么来了
- 在C++中,是否有内置的方法来计算编译时的功率
- 模板元编程可以用来加密编译时常数数据吗
- 为什么分段错误来了
- 错误:cout 未声明,并且给我带来了编译问题
- 我在pgm映像上有一个用于sobel运算符的c++代码,我的代码进行了编译,但未能给出所需的结果
- 创建一个构建框架来支持编译支持多个平台的代码
- 如何制作一个makefile来同时编译C、c++和Java文件
- 当试图构建示例代码时,我得到了编译错误
- C++最烦人的解析又来了
- NetBeans c++的方式来检查编译用调试的代码
- 我写了这个程序来反转链表中的元素,在编译这个程序后,在reverse()中显示错误.为什么