Delphi: Record constructor vs factory function

后端 未结 4 2010
再見小時候
再見小時候 2021-02-12 20:25

So what will be the preferred way of initializing records?

With a \'factory function\':

TMyRecord = record
  valueX: integer;
  valueY: integer;
end;

fu         


        
4条回答
  •  日久生厌
    2021-02-12 21:04

    I usually don't create constructors for records. It's not compatible with all versions (and FPC). Moreover typically they are used only in one place and often a fillchar is enough.

提交回复
热议问题