Created
November 1, 2013 09:28
-
-
Save ncaq/7263027 to your computer and use it in GitHub Desktop.
structではできるのに,classでできないのはなぜだ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct S | |
{ | |
this(in int val)inout | |
{ | |
val_ = val; | |
} | |
private int val_; | |
} | |
class C | |
{ | |
this(in int val)inout | |
{ | |
val_ = val; | |
} | |
private int val_; | |
} | |
class C2 | |
{ | |
this(in int val) | |
{ | |
val_ = val; | |
} | |
this(in int val)immutable | |
{ | |
val_ = val; | |
} | |
private int val_; | |
} | |
void main() | |
{ | |
S ms = S(0);//OK | |
immutable S ims = S(0);//OK | |
C mc = new C(0);//NG | |
immutable C imc = new immutable C(0);//NG | |
C2 mc2 = new C2(0);//OK | |
immutable C2 imc2 = new immutable C2(0);//OK | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment