fork download
  1. import std.stdio;
  2.  
  3. struct S {
  4. int i;
  5. }
  6.  
  7. class C {
  8. int j;
  9. }
  10.  
  11. void main() {
  12. S s;
  13. writeln(s);
  14.  
  15. S s0 = s;
  16. writeln(s0);
  17.  
  18. auto s1 = s;
  19. writeln(s1);
  20.  
  21. // This won't compile; it yields:
  22. // Error: cannot implicitly convert expression (new S) of type S* to S
  23. //S s2 = new S;
  24.  
  25. // But this compiles...
  26. auto s2 = new S;
  27.  
  28. writeln(s2);
  29. writeln(*s2);
  30. writeln(s2.i);
  31.  
  32. C c = new C();
  33. writeln(c);
  34. }
Success #stdin #stdout 0.02s 2128KB
stdin
Standard input is empty
stdout
S(0)
S(0)
S(0)
B7554DF0
S(0)
0
prog.C