关于iostream和c++命名空间

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

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

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

2. using the "suing" key wordui

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

3. the most convenient is to useing namespace stdcode

 

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:ci

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

相关文章
相关标签/搜索