1. 程式人生 > >Python中類的繼承,函式過載,匿名物件

Python中類的繼承,函式過載,匿名物件



class CEmployeeBase:
 def __init__(self,val):
  self.opt,self.target=self.subclassfunc()
  print("opt={},target={}".format(self.opt,self.target))
 def subclassfunc(self):
  print("Call sub class function")

class CEmployee(CEmployeeBase):

 def subclassfunc(self):
  opt=12
  target=1
  return opt, target
 
  
def testCEmployee(Test):
 print("Call class function automatically")
 
val=1
testCEmployee(CEmployee(val))