Вы смотрели на определение класса bitset?Где-то что-то вроде этого:
template<size_t _Bits>
class bitset
{
...
class reference;
...
}
Это очень похоже на размещение тела функции вне тела класса.Теперь мы помещаем тело вложенного класса за пределы родительского класса:
class bitset::reference
{
/* class body */
}
Кстати, в MSVC (C:\Program Files\Microsoft Visual Studio 9.0\VC\include\bitset
) они фактически определены внутри друг друга:
// TEMPLATE CLASS bitset
template<size_t _Bits>
class bitset
{ // store fixed-length sequence of Boolean elements
typedef unsigned long _Ty; // base type for a storage word
enum {digits = _Bits}; // extension: compile-time size()
public:
typedef bool element_type; // retained
// CLASS reference
class reference
{ // proxy for an element
friend class bitset<_Bits>;
.
.
.
То же самое относится к bitset.h
в g ++, хотя и немного сложнее.