Exercise 44b - composition
Posted petitherisson
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Exercise 44b - composition相关的知识,希望对你有一定的参考价值。
class Other(object):
def override(self):
print("OTHER override()")
def implicity(self):
print("OTHER implicity()")
def altered(self):
print("OTHER altered()")
class Child(object):
def __init__(self):
self.other = Other()
def implicity(self):
self.other.implicity()
def override(self):
print("CHILD override()")
def altered(self):
print("CHILD, BEFORE OTHER altered()")
self.other.altered()
print("CHILD, AFTER OTHER altered()")
son = Child()
son.implicity()
son.override()
son.altered()
output
OTHER implicity()
CHILD override()
CHILD, BEFORE OTHER altered()
OTHER altered()
CHILD, AFTER OTHER altered()
2019-10-03
02:09:04
以上是关于Exercise 44b - composition的主要内容,如果未能解决你的问题,请参考以下文章