functions cannot be const or auto

popka popka at dodgit.com
Thu Dec 13 10:09:47 PST 2007


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?

Many thanks.



More information about the Digitalmars-d mailing list