Advertisement
Guest User

Untitled

a guest
Oct 8th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.35 KB | None | 0 0
  1. struct S
  2. {
  3.     @disable this();
  4.     this(int x) { writeln("ctor ", x); }
  5.  
  6.     void opAssign(S s) {
  7.         writeln("assign");
  8.     }
  9.  
  10.     ~this() { writeln("dtor"); }
  11. }
  12.  
  13. class A
  14. {  
  15.     S s;
  16.     this() {
  17.         s = S(1); // opAssign/dtor is called instead of constructor??
  18.     }
  19. }
  20.  
  21. S s; // error. why??
  22. static this() {
  23.     s = S(1);
  24. }
  25.  
  26. void main() {
  27.     auto a = new A;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement