为什么visual studio代码告诉我cout不是std名称空间的成员?

Nir*_*bag 12 c++ c++11 visual-studio-code

我正在尝试设置visual studio代码以用c ++编程.我已经安装了扩展C/C++C/C++ Intellisense

以下是我的代码:

#include<iostream>
using namespace std;

int main()
{
 cout<< "hello" ;
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是identifier cout is undefined当我把它写成std::cout错误时,我得到的是namespace std has no member cout.以下是我的task.json档案:

{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
    {
        "taskName": "Makefile",
        // Make this the default build command.
        "isBuildCommand": true,
        // Show the output window only if unrecognized errors occur.
        "showOutput": "always",
        // No args
        "args": ["all"],
        // Use the standard less compilation problem matcher.
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["relative", "${workspaceRoot}"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
]
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

Aru*_* CM 21

这是一个错误 !!!!

这个错误有一个解决方法,转到VS代码中的文件 - >首选项 - >设置并更改

"C_Cpp.intelliSenseEngine": "Default""C_Cpp.intelliSenseEngine": "Tag Parser"

  • 仅供参考:这个错误及其解决方案仍然存在。我的 VSCode 版本是:`版本:1.45.0,提交:d69a79b73808559a91206d73d7717ff5f798f23c`。再次感谢您的解决方案!:) (2认同)