Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: gnu.g++.bug Subject: Another possible G++ bug? Message-ID: Date: 17 Jan 90 20:09:16 GMT Sender: davidm@cimshop.UUCP Distribution: gnu Organization: Consilium Inc., Mountain View, California. Lines: 61 The following test program illustrates what I think is a problem with G++. I am using G++ 1.36.1 on SunOS 3.5. The problem concerns improper use of the private data of a parent class by a child class member method. The program compiles fine and runs fine with the expected result (depending on your line of thought): N=3 X=1 ---------------- Code follows ---------------- #include class A { int x; public: A() { x = 1; } ~A() {} print() { cout << x << "\n"; } }; class B { static A* aptr; public: B(A* a) { aptr = a; } ~B() {} }; class C:B { int n; public: C(A* a, int z):(a) { n = z; } ~C() {} void testfunc(); }; void C::testfunc() { cout << "N=" << n << "\n"; cout << "X="; aptr->print(); } int main() { A testa; C testc(&testa, 3); testc.testfunc(); } ---------------- -- =================================================================== David Masterson Consilium, Inc. uunet!cimshop!davidm Mt. View, CA 94043 =================================================================== "If someone thinks they know what I said, then I didn't say it!"