error: `cout' was not declared in this scope

原因:
C++ 1998 要求cout and endl被调用使用'std::cout'和'std::endl'格式,或using namespace std;

修改后:
#include<iostream>

std::cout << "Hello World!" << std::endl;

或者

#include<iostream>
using namespace std;

猜你喜欢

转载自www.cnblogs.com/ProtoDrive/p/9775858.html