[Issue 6080] Statically constructed Structs - Constructor/Initialization ambiguity
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 31 04:17:25 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6080
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #3 from bearophile_hugs at eml.cc 2011-05-31 04:13:00 PDT ---
Please, don't link code that's in external paste sites, because their pages are
often ephemeral. The code, with small changes:
import core.stdc.stdio: printf;
struct Foo {
int a = 2;
int b = 3;
this(int c) {
a = c / 2;
b = c * 2;
}
this(float c) {
a = cast(int) c / 2;
b = cast(int) c * 2;
}
static Foo F1 = Foo(4.3);
static Foo F2 = Foo(5);
}
void main() {
printf("%d %d\n", Foo.F1.a, Foo.F1.b); // 2 8
printf("%d %d\n", Foo.F2.a, Foo.F2.b); // 5 3
Foo F3 = Foo(5);
printf("%d %d\n", F3.a, F3.b); // 2 10
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list