fork download
  1. import std.stdio;
  2.  
  3. MyClass mc;
  4.  
  5. void main()
  6. {
  7. mc = new MyClass("dimon");
  8. testClass tc = new testClass();
  9. tc.say();
  10. }
  11.  
  12. class MyClass
  13. {
  14. this(string name)
  15. {
  16. x = name;
  17. }
  18.  
  19. string x;
  20. void say()
  21. {
  22. writeln("Say hello " ~ x);
  23. }
  24.  
  25. }
  26.  
  27.  
  28. class testClass
  29. {
  30. MyClass mc = new MyClass("vasya");
  31.  
  32. void say()
  33. {
  34. mc.say();
  35.  
  36. .mc.say();
  37. }
  38. }
Success #stdin #stdout 0s 2676KB
stdin
Standard input is empty
stdout
Say hello vasya
Say hello dimon