编译时出现的问题:
1、Linux C++ 编程“cout作用域中尚未声明”解决办法
解决办法:
方法一:在 #include 下面加上一句“using namespace std;”
方法二:在使用cout时将cout替换为std::cout
这个问题在用string的时候也存在同样的问题。
所以使用#include <string>之后,也要加上using namespace std;才可以使用string定义对象。
总结:
使用cout要#include <iostream>,使用string要#include <string>,但是还要声明using namespace std;
参考文档:
namespace:http://it.dengchao.org/linux-c-cout-problem/linux/cc/
string详解:http://hi.baidu.com/zkheartboy/blog/item/7fca23fae628578b9f5146d0.html