This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/7000: Compiler not picking up inherited function from base-class


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

From: =?iso-8859-1?q?F=20ker?= <f_ker@yahoo.co.uk>
To: Gabriel Dos Reis <gdr@codesourcery.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7000: Compiler not picking up inherited function from base-class
Date: Tue, 11 Jun 2002 22:47:36 +0100 (BST)

  --- Gabriel Dos Reis <gdr@codesourcery.com> wrote: >
 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 <vector>
 > | #include <algorithm>
 > | 
 > | template<typename RefToPtrFObjConvertor_T_>
 > | 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<Vertex>
 > |   {
 > |   public:
 > |     bool value;
 > | 
 > |     SetIsTransformedFlag(bool arg)
 > |      : value(arg)
 > |     {
 > |     }
 > | 
 > |     void
 > |     operator()(Vertex& v)
 > 
 > This declaration hides
 > RefToPtrFObjConvertor<Vertex>::operator()(Vertex*).
 > Hence the error message (perhaps cryptic).  
 > 
 > -- Gaby 
 
 I asked 4 apparent 'experts' about this, none of them picked it up,
 which is very hard to believe.  Many thanks, and sorry for the
 misinformed post.
 
 
 
 __________________________________________________
 Do You Yahoo!?
 Everything you'll ever need on one web page
 from News and Sport to Email and Music Charts
 http://uk.my.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]