开发者

Constructors in cases of inheritance (Squeak)

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 to self, 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 and super 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜