playing around with D
Lionello Lunesu
lio at lunesu.remove.com
Mon Mar 5 06:22:16 PST 2007
Don Clugston wrote:
> Carsten Scharfenberg wrote:
>> 4.
>>
>> By the way: what is the difference between
>> static const int and const int ?
>> Both variants work in the examples above.
>
> I don't know what 'static const int' means. IMHO, it should be a
> compiler error, since you're mixing storage classes (unlike C++, in D,
> 'const' really means constant). Use 'const int' instead.
"static" is ignored in the global scope. And note that "const"s can have
different values per instance:
class X {
const int member;
this(int x) { member = x; }
//...
}
This is still allowed. Don't ask me why, I think it's confusing.
L.
More information about the Digitalmars-d
mailing list