Article View: comp.std.c++
Article #628Accesibility change in virtual functions
From: Anil Pal
Date: Fri, 07 Dec 1990 20:59
Date: Fri, 07 Dec 1990 20:59
50 lines
1815 bytes
1815 bytes
I am posting this for Martin Hitz, who does not have posting access to the net.
Please send e-mail replies to Martin at hitz@csi.UOttawa.CA.
Note: I checked that this is the neahiour of cfront 2.o also, and
indeed is explicitly stated in the ARM (p.255, section 11.6). Martin
would like to raise the issue for discussion, hence I am posting to
comp.lang.c++ and comp.std.c++.
--
Anil A. Pal, Silicon Graphics, Inc.
pal@sgi.com (415)-335-7279
<===== Begin forwarded message =====>
From hitz@csi.UOttawa.CA Tue Dec 4 09:47:20 1990
Date: Tue, 4 Dec 90 12:43:56 EST
From: hitz@csi.UOttawa.CA (Martin Hitz)
Message-Id: <9012041743.AA22998@csi.UOttawa.CA>
To: pal@csi.UOttawa.CA
Subject: comp.lang.c++
Status: RO
I find it awkward that it is possible (at least with g++ and Zortech 2.0)
to implicitely call a private member function via the virtual mechanism as
in the following example:
class B {
public:
virtual void f() { cout << "B\n"; }
};
class D: B {
void f() { cout << "D\n"; }
};
main()
{
D d;
B& b = d;
b.f(); // prints "D"
}
My opinion is that this shouldn't be possible, i.e. the compiler
should complain about the private version of f() in the derived
class D.
Any comments?
Best regards, Martin Hitz
hitz@csi.UOttawa.CA
Technical Details
Message-ID:
<1990Dec7.205909.14021@relay.wpd.sgi.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!sgihub!dragon!xanadu.wpd.sgi.com!palShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!sgihub!dragon!xanadu.wpd.sgi.com!pal From: pal@xanadu.wpd.sgi.com (Anil Pal) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Accesibility change in virtual functions Message-ID: <1990Dec7.205909.14021@relay.wpd.sgi.com> Date: 7 Dec 90 20:59:09 GMT Sender: news@relay.wpd.sgi.com ( CNews Account ) Reply-To: hitz@csi.UOttawa.CA Organization: Silicon Graphics, Inc. Lines: 50