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