test_a.h中有定义:
namespace ns {
class a {...};
}
test_b.h中有定义:
namespace ns {
class b {...};
}
test_c.h中有定义:
namespace ns {
class c {...};
}
然后,在test_c.cpp中有如下代码片段:
#include "test_a.h"
#include "test_b.h"
#include "test_c.h"
using namespace ns;
对于命名空间是否会产生二义性?这样做的好处是什么?
(字体显示有问题,莫怪)

C++可以在多个头文件中重复定义同一名称的命名空间吗?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- oyljerry 2016-04-28 13:59关注
这样就会合并多个命名空间 只要名称不相同冲突
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报