1.5 重名问题

使用命名空间,可以避免重名问题

例如:

#include<iostream>
namespace a{
    int x = 8;
}
namespace b{
    int x = 9;
}
int main(){
    int x = 10;
    std::cout << a::x << b::x << x << std::endl;
    return 0;
}

 

posted @ 2015-05-14 12:59  cppstudy  阅读(123)  评论(0编辑  收藏  举报