Recent

Author Topic: Extended Record  (Read 5268 times)

SonnyBoyXXl

  • Jr. Member
  • **
  • Posts: 57
Extended Record
« on: November 02, 2021, 10:57:22 pm »
The advanced records are a cool feature. Would it be possible to implement a type of inheritance like this way:

Code: Pascal  [Select][+][-]
  1. TMyRecord = record
  2.     x: integer;
  3.     y: integer;
  4. end;
  5.  
  6. TMyRecord2 = extends record (TMyRecord)
  7.     z: integer;
  8. end;
  9.  

So TMyRecord2 will have 3 elements: x,y, and z

ASerge

  • Hero Member
  • *****
  • Posts: 2246
Re: Extended Record
« Reply #1 on: November 03, 2021, 01:25:46 am »
Code: Pascal  [Select][+][-]
  1.   TMyRecord = object
  2.     X: Integer;
  3.     Y: Integer;
  4.   end;
  5.  
  6.   TMyRecord2 = object(TMyRecord)
  7.     Z: Integer;
  8.   end;
Without virtual functions, its size is the same as the records.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5486
  • Compiler Developer
Re: Extended Record
« Reply #2 on: November 05, 2021, 01:58:37 pm »
The advanced records are a cool feature. Would it be possible to implement a type of inheritance like this way:

No. If you need inheritance then use object.

 

TinyPortal © 2005-2018