Article View: gnu.g++.bug
Article #1363public in derived clashes with private in base class
From: Paul Stravers
Date: Fri, 08 Jan 1993 01:59
Date: Fri, 08 Jan 1993 01:59
41 lines
1658 bytes
1658 bytes
This reports a bug in g++ version 2.3.1 and 2.3.3.
If a derived class has a method that has the same name as a private member in
its base class then g++ does not allow access to the public method. Example:
------------------------------------------------------------------------------
class base
{
private:
char *hello;
};
class derived: public base
{
public:
char *hello() {return "hello, world!";}
};
main()
{
derived thing;
thing.hello();
}
------------------------------------------------------------------------------
Compiling this code gives:
% g++ -v
Reading specs from /usr/local/lib/gcc-lib/hp700-hpux/2.3.3/specs
gcc version 2.3.3
% g++ test.C
test.C: In function `int main ()':
test.C:16: member `hello' is private
Cfront does not complain, but then again: ``Lang leve GNU!''
Paul Stravers
--
Delft University of Technology | email stravers@donau.et.tudelft.nl
Faculty of Electrical Engineering | fax +31 15 786190
Mekelweg 4 | ph. +31 15 786280
2628 CD Delft |
the Netherlands |
Technical Details
Message-ID:
<9301072359.AA05503@muresh.et.tudelft.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!muresh.et.tudelft.nl!straversShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!muresh.et.tudelft.nl!stravers From: stravers@muresh.et.tudelft.nl (Paul Stravers) Subject: public in derived clashes with private in base class Message-ID: <9301072359.AA05503@muresh.et.tudelft.nl> Sender: gnulists@ai.mit.edu Reply-To: Paul Stravers <stravers@donau.et.tudelft.nl> Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 8 Jan 1993 01:59:14 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 42