首页 > 移动平台 > 详细

关于iostream和c++命名空间

时间:2018-03-01 22:33:20      阅读:224      评论:0      收藏:0      [点我收藏+]

c++标准库函数都在std这个命名空间中,想要使用必须加上using namespace std,下面给出几种使用方法

1. specify the identifier directily, for example std::ostream instead of ostream. the complete sentence is as follows:

std :: cout << std :: hex << 3.4 << std :: endl;

2. using the "suing" key word

using std :: cout;
using std :: endl;
The above code can be written as
cout << std :: hex << 3.4 << endl;

3. the most convenient is to useing namespace std

 

all identifier defined in namespace std are valid, as if they were declared as global varibales. Then the above statement can be written as follows:

cout << "i didn‘t pass the cet four" << "ma mai pi";

关于iostream和c++命名空间

原文:https://www.cnblogs.com/1915884031A-qqcom/p/8490696.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!