代码中的 C++ 标准错误
c++ std error in code
我刚开始 c++
这是一个基本主声明的代码,基于我找到的许多教程,还包含将 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 智能感知: 命名空间 "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";
}
现在应该没事了
相关文章:
- 编译器现在遵循C++14标准,我的项目不再编译神秘的SFML错误
- 如何从标准输入中检测格式化输入错误?
- 张量流错误 此文件需要编译器和库支持 ISO C++ 2011 标准
- 我想获取点的属性,它报告错误 C3867:"point::output_x":非标准语法;使用"&"创建指向成员的指针
- C++标准视窗 SDK 文件中的编译错误
- 提升多精度浮点数128:标准::exp错误:'no matching function for call'
- 常量转发引用给出错误 C2440:"正在初始化":无法从"常量标准::字符串"转换为"常量标准::字符串 &&"
- 分段错误标准::矢量<标准::字符串>
- 从标准::未来<void>到非标量标准::未来<bool>引发的错误转换
- 标准库to_string(双精度)在 vs2015 中给出错误的值.有什么解决办法吗?
- 代码中的 C++ 标准错误
- IOS 目标链接 cocoa 堆栈库,该库写入 C++11 标准错误
- 如何在C++中读取 bash 标准错误
- 如何从库标准错误中读取
- 添加带有自定义标准错误的 fprintf() 语句后,标准输出挂起
- 是否有一种方法可以查看哪个线程正在使用gdb打印标准输出或标准错误?
- 在c# GUI项目上重定向标准输出+标准错误
- 即使重定向了标准输出和标准错误,Unix程序如何在屏幕上显示输出?
- 发送标准错误的可能形式
- 如何从分离的QProcess中读取标准输出/标准错误