首页 > 编程语言 >c++报错:[Error] 'cout' was not declared in this scope

c++报错:[Error] 'cout' was not declared in this scope

时间:2022-11-20 11:02:25浏览次数:49  
标签:declared cout int namespace 报错 scope

一、报错代码

#include <iostream>

int main() {
    int x=10;
    cout<< x <<"\n";
    return 0;
}

 

二、解决方法

在代码中加入:

using namespace std;

正确代码:

#include <iostream>
using namespace std;

int main() {
    int x=10;
    cout<< x  <<"\n";
    return 0;
}

运行结果:

 

 

φ(゜▽゜*)♪ 感谢观看,希望对你有帮助!

标签:declared,cout,int,namespace,报错,scope
From: https://www.cnblogs.com/yihong-song/p/16908026.html

相关文章