vs2015 debug时出现 C2039“cout”: 不是“std”的成员

今天想起电脑上的vs2015,发现好久没用了,用了下,遇到了一个问题

由于不常用c++,还是觉得应该记录下来,以免下次遇到,不知怎么处理

新建项目Hello

Hello.cpp

#include "stdafx.h"

int main()
{
    std::cout << "hello world!I'm C++." << std::endl;
    system("pause");
    return 0;
}

debug时出现

严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C2039 “cout”: 不是“std”的成员 Hello e:\c\hello\hello\hello.cpp 8

 

解决的方法:

  包含命名空间std所在的头文件iostream

#include <iostream>

下面的可以正常运行

#include "stdafx.h"
#include <iostream>
int main()
{
    std::cout << "hello world!I'm C++." << std::endl;
    system("pause");
    return 0;
}

复制代码
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
    cout << "hello world!I'm C++." << endl;
    system("pause");
    return 0;
}
复制代码

 

posted @   慕尘  阅读(6844)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示