Forum > Beginners

What is the difference between the new ADVANCED RECORD and the old OBJECT?

(1/13) > >>

malcome:
What is the difference between the new ADVANCED RECORD and the old OBJECT?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- {$mode objfpc}{$H+}{$modeswitch ADVANCEDRECORDS} type  TOld = object  private    function getheight: integer;    procedure setheight(AValue: integer);  public    property Height: integer read getheight write setheight;  end;   TNew = record  private    function getheight: integer;    procedure setheight(AValue: integer);  public    property Height: integer read getheight write setheight;  end; var  Fnew: TNew;  Fold: TOld; begin  Fnew.Height := 100;  Fold.Height := 200;  writeln(Fnew.Height);  writeln(Fold.Height);end.   
Thank you.

GetMem:
@malcome

Try to inherit something from TOld then from TNew and you'll see the difference. ;)

malcome:
Hi GetMem.
Only that? :o IMHO,it is atrophy.:D

marcov:
Make a method virtual in the object case, and compare the sizeofs()

Graeme:

--- Quote from: malcome on December 10, 2015, 09:17:34 am ---What is the difference between the new ADVANCED RECORD and the old OBJECT?

--- End quote ---

Delphi broke OBJECT support and reinvented the wheel a couple years later with "advanced records".  In FPC  you require an extra compiler mode to enable advanced records.

FPC has never broken OBJECT's, and they are the precursor to CLASS. I like them and use them often. I may be old school (from my TP days), but for me a RECORD is a structure without methods, so that's why I don't use Advanced Records in any of my code.

In the end I guess they do the same thing though.

Navigation

[0] Message Index

[#] Next page

Go to full version