yesraaj
yesraaj

Reputation: 47900

Interaction of namespace and friend in C++?

Is it possible to make a namespace 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.

Upvotes: 5

Views: 2624

Answers (2)

anon
anon

Reputation:

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

Upvotes: 1

Konamiman
Konamiman

Reputation: 50273

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.

Upvotes: 0

Related Questions