Article View: comp.std.c++
Article #347Re: Inheritance in cfront and g++
From: Dave Astels
Date: Fri, 17 Aug 1990 14:17
Date: Fri, 17 Aug 1990 14:17
37 lines
1727 bytes
1727 bytes
In article <FOX.90Aug15101045@devo.allegra.att.com> fox@allegra.att.com (David Fox) writes:
>In porting code from g++ to cfront I have come across the following
>inconsistancy. The following program compiles as-is in g++
>
> class A {
> public:
> void f(int);
> };
>
> class B : public A {
> public:
> void f(char*);
> //void f(int i) {A::f(i);}
> };
>
> main()
> {
> B x;
> x.f(3);
> }
>
>And the call to x.f(3) finds the function f in class A. In
>cfront, however, the function f in class B "masks" the f in
>class A, so you need the commented f(int) member function to
>get this to compile. To me, the g++ semantics make more sense.
>Do others agree?
I feel as you do. B::f(char *) shouldn't override A::f(int).
Unfortunately Zortech (2.06) doesn't aggree. It works as cfront does.
I would think that overriding would take place using the mangled name.
Thus f(int) would be completely different than f(char *).
--
"I liked him better before he died" - McCoy, ST V
===============================================================================
Dave Astels | Internet: 880716a@AcadiaU.CA
PO Box 835, Wolfville, | Bitnet: 880716a@Acadia
Technical Details
Message-ID:
<1990Aug17.141710.5004@aucs.uucp>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!cs.dal.ca!aucs!880716aReferences:
<FOX.90Aug15101045@devo.allegra.att.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!cs.dal.ca!aucs!880716a From: 880716a@aucs.uucp (Dave Astels) Newsgroups: comp.std.c++ Subject: Re: Inheritance in cfront and g++ Message-ID: <1990Aug17.141710.5004@aucs.uucp> Date: 17 Aug 90 14:17:10 GMT References: <FOX.90Aug15101045@devo.allegra.att.com> Reply-To: 880716a@aucs.UUCP (Dave Astels) Distribution: comp Organization: School of Computer Science, Acadia Univ., Nova Scotia Lines: 37