错误:'cout':未声明的标识符;虽然我已经在程序中包含了iostream头文件
Error: 'cout' : undeclared identifier; though I've included iostream header file in program
我试图在下面编译简单的程序。但是,它不是编译&给出错误:
error C2065: 'cout' : undeclared identifier
我想问你,尽管我在其中包含了 iostream
标头文件,但为什么这个程序不起作用?
#include <iostream>
void function(int) { cout << “function(int) called” << endl; }
void function(unsigned int) { cout << “function(unsigned int) called” << endl; }
int main()
{
function(-2);
function(4);
return 0;
}
预先感谢。
COUT流在STD名称空间中定义。为了命名您写的:
std::cout
如果您想将其缩短到cout,则可以写
using namespace std;
或
using std::cout;
写Cout。
任何好的文档源都会告诉您哪个名称空间包含一个对象。例如:http://en.cppreference.com/w/cpp/io/cout
您必须编写std::cout
或添加using std;
相关文章:
- 使用mongocxx驱动程序时包含头文件问题
- 如果第一个元素包含任何零,则我的程序以不希望的方式运行
- 将 C# 对象(包含静态对象成员)作为参数传递给 C++/CLI 程序
- (Wix 安装程序)如何包含自定义操作依赖项
- 如何在C++的凯撒密码程序中包含空格?
- 程序检查字符串是否只包含 1 和 0?
- 程序只适用于包含(无副作用)cout声明
- 在Qt应用程序中包含Python.h会导致对Qt函数的未定义引用
- 如何为包含 protobuf 库的C++程序生成共享库 (.so) 文件
- 在VS2019中包含nuget包C++跨平台程序
- 当我在结构中包含多个数组时,我的程序会跳过一堆代码
- 标头包含不是 .c 程序所必需的,而是.cpp程序需要的
- 通过包含<iostream>头文件,它的所有 8 个函数是写入我的代码,还是只写入我在程序中使用的函数?
- 如何允许我的程序成功读取数字包含的文件
- 崇高文本 3 - 在终端中编译并运行 C++ 程序(路径包含空格)
- 如何将视觉C++重新分发包含在应用程序中
- 通过程序代码行设置C++包含路径
- 在静态库中使用Boost会导致应用程序包含Boost
- 如果程序包含以下代码,则可能会崩溃.为什么
- 在linux容器中运行c++程序(包含TCP IP代码)