const methods()

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Mon Jan 22 06:04:53 PST 2007


Mike wrote:
> D doesnt seem to have any way of protecting a class object from being changed
> by non-const functions. For example in C++ I can declare a class reference as
> const, so no one can call any methods on that reference that would change the
> contents of the object. Why can you not do this in D? What is the alternative
> line of thought to this?

There's not really an alternative line of thought involved, except in 
the sense that the way C++ does const sucks :P.

Active work is currently being done to design a way to do const (and 
some other things) that is hopefully better.
Until then, we'll have to do without :(.



More information about the Digitalmars-d mailing list