# -*- encoding:utf-8 -*-

class myBase(object):
	"""docstring for myBase"""
	def __init__(self):
		super(myBase, self).__init__()

	def function(self):
		self.function_child()			#在父类中调用子类的方法,在C++中不可以
		print(self.name)				#在父类中调用子类的数据成员,在C++中不可以


class myChild(myBase):
	"""docstring for myChild"""
	def __init__(self, name):
		myBase.__init__(self)						#调用父类的方法:直接法 形如:parentclass.parentattribute(self,[arg]),使用父类名称直接调用
		#super(myChild, self).__init__()			#调用父类的方法:super函数,形如:super(childclass, childobj).parentattribute([arg])
		#super().__init__()							#调用父类的方法 super函数省略法,形如:super().parentattribute([arg])

		self.name = name

	def function_child(self):
		print("function_child")

mych = myChild("child")
mych.function()

#mybase = myBase()
#mybase.function()						#报错,提示在myBase 对象中没有name属性