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;
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐