#! / usr/bin/pythonlớp phụ huynh: # xác định phụ huynh lớp parentAttr = 100 def __init__(self): in "Nhà xây dựng phụ huynh điện thoại" def parentMethod(self): in 'Gọi phương pháp phụ huynh' def setAttr (tự, attr): Parent.parentAttr = attr def getAttr(self): in "thuộc tính cha mẹ:", Parent.parentAttrlớp Child(Parent): # xác định trẻ em lớp def __init__(self): in "Gọi trẻ em nhà xây dựng" def childMethod(self): in 'Gọi phương pháp trẻ em'c = Child() # thể hiện của trẻ emc.childMethod() # trẻ em gọi của phương phápphương pháp c.parentMethod() # cuộc gọi chac.setAttr(200) # lại gọi phương pháp của cha mẹc.getAttr() # lại gọi phương pháp của cha mẹ
đang được dịch, vui lòng đợi..
