错误:未声明cout,这给了我编译问题 [英] error: cout was not declared and is giving me compiling problems

查看:81
本文介绍了错误:未声明cout,这给了我编译问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#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。
警告:字符常量的类型太长(默认情况下启用)

I keep getting error: 'cout' was not declared in this scope. warning: character constant too long for its type (enabled by default)

推荐答案

您需要

#include <iostream>

在这里定义 std :: cout 。 (而且您不需要 #include< ostream> 。)

That's where std::cout is defined. (And you don't need #include <ostream>.)

这篇关于错误:未声明cout,这给了我编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆