c++报错:[Error] 'cout' was not declared in this 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;
}

运行结果:

 

 

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

posted @ 2022-11-20 10:52  Mr_宋先生  阅读(679)  评论(0编辑  收藏  举报