functions cannot be const or auto

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Dec 13 10:28:11 PST 2007


"popka" <popka at dodgit.com> wrote in message 
news:fjrshb$1j2j$1 at digitalmars.com...
> Hi all,
>
> I'm new to D and I've encountered an error message which is confusing me. 
> I am trying to write a 'const' member function, i.e. one which does not 
> modify the object.
>
> If I understand correctly, the D syntax for this is:
>
> class Foo {
>  const void f() {}
> }
>
> However, this gives me the following error:
>
> test.d(2): function test.Foo.f functions cannot be const or auto
>
> I have tried this using both DMD and GDC. What am I doing wrong?

You're using the D1 compiler, not the D2 compiler.  Only D2 has constness.

As far as I know there is no D2-compatible GDC, only DMD. 





More information about the Digitalmars-d mailing list