开发者

Interaction of namespace and friend in C++?

开发者 https://www.devze.com 2022-12-14 14:12 出处:网络
Is it possible to make a 开发者_StackOverflownamespace friend of a class, say I have a unit test namespace with many classes and I wanted the test namespace to be friend to a class so that it has acce

Is it possible to make a 开发者_StackOverflownamespace friend of a class, say I have a unit test namespace with many classes and I wanted the test namespace to be friend to a class so that it has access to private implementation details.


No, this is not possible in C++. Frankly, it smacks of poor design.


If you are using .NET, you may want to take a look at the InternalsVisibleTo attribute. Anyway note that this works for whole assemblies, not for single namespaces.

0

精彩评论

暂无评论...
验证码 换一张
取 消