以前没搞懂为啥输出语句cout前面还要加std:: ,不懂为啥?
以前学的C++知识也忘记了,现在看了ns的书才知道。
ns3中使用是名字空间是:
cout不是ns3这个命名空间中的函数,但是你想在ns3中调用cout函数,所以,就要加命名空间;
解释:
例子:加了命名空间和不加命名空间的却别;
有了命名空间using namespace std; 在调用函数的时候就不用加 std::
下面两段代码功能完全一样:
代码一:
#include
int main()
{undefined
std::cout << “Hello world!!!” << std::endl;
return 0;
}
代码二:
#include
using namespace std;
int main()
{
cout << “Hello world!!!” << endl;
return 0;
}