本節書摘來自異步社群出版社《c++遊戲程式設計入門(第4版)》一書中的第1章,第1.3節,作者:【美】michael dawson(道森),更多章節内容可以通路雲栖社群“異步社群”公衆号檢視。
c++遊戲程式設計入門(第4版)
因為經常要用到std名稱空間中的元素,在此介紹兩種不同的可以直接使用這些元素的方法,這樣就不必總是使用std::字首。
game over 2.0程式的運作結果和圖1.2所示的原始game over程式一模一樣,但是差別在于通路std名稱空間中元素的方式。從cengage learning網站(www.cengageptr.com/downloads上可以下載下傳到該程式的代碼。程式位于chapter 1檔案夾中,檔案名為game_over2.cpp。
// game over 3.0
// demonstrates using declarations
using std::cout;
using std::endl;
int main()
{
cout << "game over!" << endl;
return 0;
}<code>`</code>
3.0版本的game over程式使用了兩個using聲明。