![](/img/trans.png)
[英]C++ source code compilation error in MinGW with std::copy function
[英]c++ std error in code
我刚开始C ++
这是基本主声明的代码,基于我发现的许多tutorails,还包含用于打印hello world到控制台的代码
// TestApp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Hello World";
}
我正在使用VS 2012 Express,我不知道使用哪个编译器,但是“ cout”用红色下划线
错误如下:
错误C2039'cout':是'std'ln 9 col 1的成员。错误C2065:未声明的标识符ln 9 col 1 IntelliSense:名称空间“ std”没有成员“ cout” ln 9 col 7
我不明白为什么会出错,请有人启发我吗?
该错误告诉您在此翻译单元中的任何地方都尚未声明std::cout
。 如果尚未声明,则不能使用。 std::cout
在C ++标准库<iostream>
头文件中声明:
#include <iostream>
如果以后收到类似的错误,并且需要知道要包含哪个标头,请查找一些文档以了解要使用的特定功能/类型。 例如,如果您查看cppreference.com ,它将显示“在标头<iostream>
定义”。
包括以下代码:
#include <iostream>
尝试这个:
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Hello World";
}
现在应该很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.