bmethods.nim 366 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. output: '''derived class
  3. base class
  4. '''
  5. """
  6. import amethods
  7. type
  8. TDerivedClass* = object of TBaseClass
  9. proc newDerivedClass: ref TDerivedClass =
  10. new result
  11. method echoType*(x: ref TDerivedClass) =
  12. echo "derived class"
  13. var b, d: ref TBaseClass
  14. b = newBaseClass()
  15. d = newDerivedClass()
  16. #b.echoType()
  17. #d.echoType()
  18. echoAlias d
  19. echoAlias b