This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7000: Compiler not picking up inherited function from base-class
- From: F ker <f_ker at yahoo dot co dot uk>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 11 Jun 2002 21:56:03 -0000
- Subject: Re: c++/7000: Compiler not picking up inherited function from base-class
- Reply-to: F ker <f_ker at yahoo dot co dot uk>
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