C++的命名空间

来源:互联网 发布:sql 批量replace 编辑:程序博客网 时间:2024/05/19 13:23
//chap1_2.cpp//A simple app to demonstrate how to use namespace.#include <iostream>using namespace::std;namespace One {    int M = 200;    int inf = 10;}namespace Two {    int x;    int inf = 100;}//using namespace::Oneint main(int argc, char *argv[]){    using Two::x;    cout << x << endl;    x = -100;    One::inf *= 1;    cout << One::inf << endl;    cout << One::M << endl;    Two::inf *= 2;    cout << Two::inf <<endl;    cout << x << endl;    return 0;}

原创粉丝点击