You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
966 B

  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. sys.path.append('.')
  5. from example import Example12, runExample12, runExample12Virtual, runExample12Bool
  6. class ExtendedExample12(Example12):
  7. def __init__(self, state):
  8. super(ExtendedExample12, self).__init__(state + 1)
  9. self.data = "Hello world"
  10. def run(self, value):
  11. print('ExtendedExample12::run(%i), calling parent..' % value)
  12. return super(ExtendedExample12, self).run(value + 1)
  13. def run_bool(self):
  14. print('ExtendedExample12::run_bool()')
  15. return False
  16. def pure_virtual(self):
  17. print('ExtendedExample12::pure_virtual(): %s' % self.data)
  18. ex12 = Example12(10)
  19. print(runExample12(ex12, 20))
  20. try:
  21. runExample12Virtual(ex12)
  22. except Exception as e:
  23. print("Caught expected exception: " + str(e))
  24. ex12p = ExtendedExample12(10)
  25. print(runExample12(ex12p, 20))
  26. print(runExample12Bool(ex12p))
  27. runExample12Virtual(ex12p)