class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
print("父类构造函数")
def talk(self):
print("person is talking....")
class Chinese(Person):
def __init__(self, name, age, language): # 先继承,在重构
Person.__init__(self, name, age) # 继承父类的构造方法,也可以写成:super(Chinese,self).__init__(name,age)
self.language = language # 定义类的本身属性
print("子类构造函数")
def walk(self):
print('is walking...')
class American(Chinese):
def __init__(self, name, age, language,height):
Chinese.__init__(self,name,age,language)
self.height=height
print("孙类构造函数")
c = American('bigberg', 22, 'Chinese',180)