c++/8577: postfix operator not inherithed

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Nov 20 17:57:00 GMT 2002


The following reply was made to PR c++/8577; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Delana.Lorenzo@libero.it
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/8577: postfix operator not inherithed
Date: 14 Nov 2002 15:06:02 +0100

 Delana.Lorenzo@libero.it writes:
 
 [...]
 
 | >Class:          sw-bug
 
 This is not a bug.
 
 [...]
 
 | class A
 | {
 | public:
 | virtual void toimplement () = 0;
 | void implemented () { toimplement(); }
 | virtual void operator ++ () = 0;
 | void operator ++ (int) { printf ("Postfix inc\n"); }
 | };
 | 
 | class B : public A {
 | public:
 | void toimplement () { printf ("IMPLEMENTATION of pure\n"); }
 | void operator ++ () { printf ("Prefix inc\n"); }
        ^^^^^^^^^^^
 
 This hides the name of the postfix function in A.
 
 In short: don't overload a virtual function.
 
 -- Gaby



More information about the Gcc-prs mailing list