Topic: implementing access specifiers for C++ namespaces
Author: jimsmithellis@gmail.com
Date: Tue, 2 Jun 2009 13:31:32 CST Raw View
When declaring a namespace that will be used by several classes in
your code, you might want to specify what classes are allowed or need
to use the data and types declared in that namespace.
This can be implemented with class definitions, but you can't say
'using class X'.
namespace SpaceX {
//Only allow classes Y and Z to access this namespace
friend class Y;
friend class Z;
...
}
namespace SpaceA {
//Make this accessible to all
public:
...
}
This increases encapsulation and makes it easier to tell where the
namespace may be used.
Best Regards,
James Smith
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: wasti.redl@gmx.net
Date: Wed, 3 Jun 2009 12:52:39 CST Raw View
On Jun 2, 9:31 pm, jimsmithel...@gmail.com wrote:
> When declaring a namespace that will be used by several classes in
> your code, you might want to specify what classes are allowed or need
> to use the data and types declared in that namespace.
Modules, if we ever get them, will offer this feature.
Sebastian
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]