I have a class A which B inherits from. The inheritance includes a bunch of parameters, and they should all be initialized to some default values in both cases (whether we create an A object or a B object). I decided to put the initialization into the constructor of A, since the creation of B should create an A first. However, this doesn't seem to be happ开发者_如何学运维ening automatically, and I was unable to figure out how to call the super constructor manually. Can some one help me out?
You already found the solution, but here are some more notes that might help you to understand your question better:
super
is similar toself
, they both represent the receiver of the message.self
starts the lookup of the following message in the receiver of the message.super
starts the lookup of the following message in the superclass where the implementing method is defined in.self
andsuper
are not messages but implicit variables, therefor you cannot find them in the message finder.
OK never mind... You use the word super. I guess that explains why there's no list of classes that define it in the method finder.
精彩评论