C++命名空间范围

#include iostreamusing namespace std;// first name spacenamespace first_space {void func() {cout Inside first_space endl;

编程学习网为您整理以下代码实例,主要实现:C++命名空间范围,希望可以帮到各位朋友。

#include <iostream>

using namespace std;

// first name space
namespace first_space {
   voID func() {
      cout << "InsIDe first_space" << endl;
   }
}

// second name space
namespace second_space {
   voID func() {
      cout << "InsIDe second_space" << endl;
   }
}

int main () {
   // Calls function from first name space.
   first_space::func();

   // Calls function from second name space.
   second_space::func(); 

   return 0;
}

本文标题为:C++命名空间范围

上一篇: C++指向类的指针
下一篇: C++基础和派生类