Need I to put overload or override words after the constructor declaration in derived class?

前端 未结 4 1008
不思量自难忘°
不思量自难忘° 2021-02-09 03:03

I have a class hierarchy, this one:

type
TMatrix = class
    protected
      //...
    public
      constructor Create(Rows, Cols: Byte);
    //...
type
  TMinMa         


        
4条回答
  •  失恋的感觉
    2021-02-09 04:04

    You need to call the inherited method explicitly; Delphi won't do it for you. This is by design, because there are cases where you're working with virtual methods, for example, when you do not want to invoke the inherited behavior.

    Also, as a matter of personal preference, I like to write out the inherited call completely. (inherited Create(Rows, Cols); as opposed to just inherited; for one simple reason: it makes it that much easier to traverse the code. If you've got a method call written out, you can control-click it and get to the ancestor method.

提交回复
热议问题