C++ frequently questioned answers
Ary Borenszweig
ary at esperanto.org.ar
Sat Oct 27 16:58:54 PDT 2007
torhu escribió:
> Ary Borenszweig wrote:
> > In D:
>>
>> class Foo {
>>
>> private {
>> int x, y;
>> }
>>
>> static {
>> float SomeGlobalVariable;
>>
>> this() {
>> // Do some global initializations
>> }
>> }
>> }
>>
>> Nope, no compiler warning here either.
>>
>> At least Eclipse gives you a warning saying "That method's name is the
>> same as the class' name". :-)
>
> Static constructors are allowed, they don't replace the regular
> constructor. Or wasn't that what you meant?
That was exactly what I meant, thanks for the response. :-)
Try compiling and running these:
1.
---
import std.stdio;
class X {
static this() {
writefln("static");
}
}
void main() {
}
---
2.
---
import std.stdio;
class X {
static {
this() {
writefln("static");
}
}
}
void main() {
}
---
More information about the Digitalmars-d
mailing list