Quote:Original post by SpreeTree
But what would the benifits of that be?
Being able to move the definition of B to its own file and out of A.
Quote:Class scope definitions of other classes are generally used to reduce the scope and give meaning to the second class, whereas the code you suggest not only leaves class B in the global namespace, but actually gives you multiple ways of defining the same object (since you have to include b.hpp to use a.hpp).
_Vector_const_iterator is a template class in the std:: namespace, but nobody ever uses it. In fact, few people even suspect its existence, and it isn't guaranteed to exist on all compilers or libraries either. Most people use std::vector<T>::const_iterator instead, even if it's just a typedef for std::_Vector_const_iterator<T>.
The fact that a class is in the global namespace (or any namespace, for that matter) doesn't mean that it's public—besides, naming it _private_impl_A::_B (with the appropriate name and namespace) is extremely easy to do, and conveys the "don't touch this class" message pretty clearly to programmers. Users should not be aware of the existence of _private_impl_A::_B and the "B.hpp" header.
Ultimately, it is the documentation of the signature of the module, and not the header files, that should be used by the programmers.