父类中调用子类函数
python中的父子类分界不是那么明确,因为在子类构造函数中调用父类构造函数时可以传递子类的self,这样父类中就知道子类函数的存在了。但是在Java中并不可以因为Java是一种强制类型的语言,this并不是一个数据实例所以实现不了父类调用子类中函数的情况。
例如:
class A:
def __init__(self):
a = 0;
def port(self):
self.out();
class B(A):
def __init__(self):
A.__init__(self)
def out(self):
print(111)
b = B()
b.port()
#在python中这并不出错