public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Gabriel Dos Reis <gdr@codesourcery.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/7000: Compiler not picking up inherited function from base-class
Date: Tue, 11 Jun 2002 14:46:00 -0000	[thread overview]
Message-ID: <20020611214607.21946.qmail@sources.redhat.com> (raw)

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

From: Gabriel Dos Reis <gdr@codesourcery.com>
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 <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


             reply	other threads:[~2002-06-11 21:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-11 14:46 Gabriel Dos Reis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-06-17  7:22 lerdsuwa
2002-06-11 14:56 F ker
2002-06-11 14:26 f_ker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020611214607.21946.qmail@sources.redhat.com \
    --to=gdr@codesourcery.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).