class Human:
def __init__(self, height, weight):
self.height = height
self.weight = weight
class Male(Human):
def __init__(self, name):
Human.__init__(self, height, weight) # This will inherit every attribute of the parent class.
self.name = name
class Female(Human):
...some more code
是的,你可以这样做,但如果你把男性和女性划分成不同的阶级,仅仅继承人类阶级,那就更好了。你知道吗
相关问题 更多 >
编程相关推荐