Extended Type Design.

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Mar 23 15:04:48 PDT 2007


Derek Parnell wrote:
>> 'const' is a guarantee that any data of that type will never be modified 
>> through a reference to that type (though other, non-const references to 
>> that type can modify the data).
> 
>  const Foo f = new Foo("nice");
>        Foo g = f;
> 

Since the above case wasn't answered, I will. The "Foo g = f;" statement 
isn't allowed at all, because you are casting a const (think readonly) 
reference to a non-const reference. That isn't allowed, by design, since 
the very purpose of const (think readonly), is to disallow the holder of 
that reference to do any changes on the reference data.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list