Java: Calling a super method which calls an overridden method

The keyword super doesn’t “stick”. Every method call is handled individually, so even if you got to SuperClass.method1() by calling super, that doesn’t influence any other method call that you might make in the future. That means there is no direct way to call SuperClass.method2() from SuperClass.method1() without going though SubClass.method2() unless you’re working with … Read more

How does Python’s “super” do the right thing?

Change your code to this and I think it’ll explain things (presumably super is looking at where, say, B is in the __mro__?): class A(object): def __init__(self): print “A init” print self.__class__.__mro__ class B(A): def __init__(self): print “B init” print self.__class__.__mro__ super(B, self).__init__() class C(A): def __init__(self): print “C init” print self.__class__.__mro__ super(C, self).__init__() class … Read more

python multiple inheritance passing arguments to constructors using super

Well, when dealing with multiple inheritance in general, your base classes (unfortunately) should be designed for multiple inheritance. Classes B and C in your example aren’t, and thus you couldn’t find a proper way to apply super in D. One of the common ways of designing your base classes for multiple inheritance, is for the … Read more

What exactly is super in Objective-C?

super Essentially, it allows you to use the implementations of the current class’ superclass. For the gritty details of the Objective-C runtime: [super message] has the following meaning: When it encounters a method call, the compiler generates a call to one of the functions objc_msgSend, objc_msgSend_stret, objc_msgSendSuper, or objc_msgSendSuper_stret. Messages sent to an object’s superclass … Read more