Advertisement
Guest User

Untitled

a guest
May 21st, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OvrldConstructor
  4. {
  5. class XYCoord
  6. {
  7. public int x, y;
  8.  
  9. public XYCoord() : this(0, 0)
  10. {
  11. Console.WriteLine("Inside XYCoord()");
  12. }
  13.  
  14. public XYCoord(XYCoord obj) : this(8, 9)
  15. {
  16. Console.WriteLine("Inside XYCoord(obj)");
  17. }
  18.  
  19. public XYCoord(int i, int j)
  20. {
  21. Console.WriteLine("Inside XYCoord(int, int)");
  22. x = i;
  23. y = j;
  24. }
  25. }
  26. class OverloadConsDemo
  27. {
  28. static void Main(string[] args)
  29. {
  30. XYCoord t1 = new XYCoord();
  31. XYCoord t2 = new XYCoord(8, 9);
  32. XYCoord t3 = new XYCoord(t2);
  33.  
  34. Console.WriteLine($"t1.x, t1.y: {t1.x}, {t1.y}");
  35. Console.WriteLine($"t2.x, t2.y: {t2.x}, {t2.y}");
  36. Console.WriteLine($"t3.x, t3.y: {t3.x}, {t3.y}");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement