您的位置:首页 > 编程语言 > Python开发

python中类的合成-----------类的基础(十一)

2016-06-17 00:00 260 查看
摘要: python 类 合成

[code=language-python]class other(object):
def over(self):
print("game over")

def im(self):
print("damned QQ")

def me(self):
print("me too")

class child(object):
def __init__(self):
self.other = other()#使用别的类,而不是继承的关系
def over(self):
self.other.over()
def im(self):
self.other.im()
def me(self):
self.other.me()

son = child()
son.over()
son.im()
son.me()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 面向对象