小编w1c*_*ckr的帖子

C2065'cout':未声明的标识符

所以我是C++的完整菜鸟,我正在尝试为作业制作一个简单的"Hello world"程序.我的代码如下:

#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
    cout<<"hello world!";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

出于某种原因,VS2017正在抛出一个错误cout,说这是未定义的.我已经对旧帖子进行了一些阅读,并添加了#include "stdafx.h以查看是否可以按照旧建议解决它,但它继续给我错误.有任何想法吗?

编辑:

再一次完整的菜鸟,但是当我搜索它时会出现多个版本的stdafx.h,这里看起来像是"主要"的:

  // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

#ifndef STRICT
#define STRICT
#endif

#include "targetver.h"

[!if SERVICE_APP]
#define _ATL_FREE_THREADED
[!else]
#define _ATL_APARTMENT_THREADED
[!endif]

#define _ATL_NO_AUTOMATIC_NAMESPACE

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS  // some CString constructors will be explicit

[!if PREVIEW_HANDLER …
Run Code Online (Sandbox Code Playgroud)

c++ stl cout visual-studio visual-studio-2017

2
推荐指数
1
解决办法
826
查看次数

标签 统计

c++ ×1

cout ×1

stl ×1

visual-studio ×1

visual-studio-2017 ×1