Problems with const/non-const overloads of member functions

Steven Schveighoffer schveiguy at yahoo.com
Fri Jun 25 06:20:12 PDT 2010


On Fri, 25 Jun 2010 09:09:07 -0400, Richard Webb  
<richard.webb at boldonjames.com> wrote:

> Using the latest DMD2, the code:
>
> //
> class c1
> {
>    void foo() const
>    {
>
>    }
>
>    void foo()
>    {
>
>    }
>
>    void bar() const
>    {
>       foo();
>    }
> }
> //
>
> fails to compile with the error:
>
> constest.d(15): Error: function constest.c1.foo () is not callable using
> argument types () const
>
> However, if i either:
> 1) Change bar() to call this.foo() or
> 2) switch the 2 foo()s so that the const version is defined second.
>
> The it compiles ok.
> There are various const related issues in the bug tracker, but i don't
> immediately see this one. Anyone know if it's a known thing?

File it anyways, if it's a repeat then it probably will just be closed as  
a duplicate.  As long as you do a reasonable effort to search, nobody can  
fault you for adding a duplicate bug :)

-steve


More information about the Digitalmars-d-learn mailing list