Article View: gnu.g++.bug
Article #648protected member access
From: Naoki Saito (GEO-002) Ext. 5471
Date: Thu, 30 Nov 1989 22:14
Date: Thu, 30 Nov 1989 22:14
46 lines
1390 bytes
1390 bytes
The function void f(Base& b) in the following program caused an error
if I used the Sun C++ 2.0 translator as follows:
""prot.cc", line 18: error: Derived::f() cannot access Base::a: protected
member
Howerver, g++-1.34.2 on the Sun3 OS 4.0.1 did not produce any error. Which
behavior is correct? (I think this is a 1.34.2 bug...) This g++ behavior is
different from the g++-1.36.x?
Thanks in advance,
Naoki Saito (saito@sdr.slb.com)
Schlumberger-Doll Research
========================prot.cc================================================
#include <stream.h>
class Base
{
protected:
int a;
public:
Base() { a = 100; }
~Base() {};
int get_a() { return a; }
};
class Derived : public Base
{
public:
Derived() : () { a = 10; }
~Derived() {};
void f(Base& b) { cout << a + b.a << "\n"; }
void g(Base& b) { cout << a + b.get_a() << "\n"; }
};
main()
{
Base x;
Derived y;
y.f(x);
y.g(x);
}
Technical Details
Message-ID:
<8911302214.AA17311@ascsu1.SLCS.SLB.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sdrvx2.sinet.slb.com!saitoShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sdrvx2.sinet.slb.com!saito From: saito@sdrvx2.sinet.slb.com (Naoki Saito (GEO-002) Ext. 5471) Newsgroups: gnu.g++.bug Subject: protected member access Message-ID: <8911302214.AA17311@ascsu1.SLCS.SLB.COM> Date: 30 Nov 89 22:14:37 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 46