python父构造函数调用继承

时间:2016-01-16 12:18:39

标签: python c++ inheritance constructor

我是python的新手,从C ++迁移到python。

class B:
   def __init__(self): 
     print "Constructor B was called"
class C(B): 
    def __init__(self): 
     print "Constructor C was called"
c = C()

上述程序的输出是

Constructor C was called

预期产出

Constructor B was called Constructor C was called

为什么不像在C ++中调用父构造函数那样调用父构造函数。

0 个答案:

没有答案
相关问题