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