Problems with const/non-const overloads of member functions

Richard Webb richard.webb at boldonjames.com
Fri Jun 25 06:09:07 PDT 2010


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?

Thanks,
Richard Webb


More information about the Digitalmars-d-learn mailing list