From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22041 invoked by alias); 11 Jun 2002 21:46:12 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21954 invoked by uid 71); 11 Jun 2002 21:46:07 -0000 Date: Tue, 11 Jun 2002 14:46:00 -0000 Message-ID: <20020611214607.21946.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Gabriel Dos Reis Subject: Re: c++/7000: Compiler not picking up inherited function from base-class Reply-To: Gabriel Dos Reis X-SW-Source: 2002-06/txt/msg00255.txt.bz2 List-Id: The following reply was made to PR c++/7000; it has been noted by GNATS. From: Gabriel Dos Reis To: f_ker@yahoo.co.uk Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/7000: Compiler not picking up inherited function from base-class Date: 11 Jun 2002 23:39:37 +0200 f_ker@yahoo.co.uk writes: [...] | I am trying to use a generic base class to supply an operator()(T*) for all classes that have an operator()(T&) - but the compiler doesn't seem to pick up the operator()(T*) from the base class, and complains and rejects the code that tried to call it. This is not a compiler misbehaviour, not a standard-conformant one. The declarations of operator()(T&) are overriding the corresponding pure virtual function in the base case _and_ *hiding* any other overloads. The moral is that you don't want to overload a pure virtual function. | Code: | | #include | #include | | template | class RefToPtrFObjConvertor | { | public: | virtual void | operator()(RefToPtrFObjConvertor_T_& arg) = 0; | | virtual void | operator()(RefToPtrFObjConvertor_T_* arg) | { | operator()(*arg); | } | | }; | | struct Vertex | { | bool is_transformed; | | class SetIsTransformedFlag | : public RefToPtrFObjConvertor | { | public: | bool value; | | SetIsTransformedFlag(bool arg) | : value(arg) | { | } | | void | operator()(Vertex& v) This declaration hides RefToPtrFObjConvertor::operator()(Vertex*). Hence the error message (perhaps cryptic). -- Gaby