Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

pascal

What are Pascal extended records?

Muhammad Ashir

Records in Pascal are user-defined variables that can hold many different items within them. Extended records were introduced by Delphi 2005 to support one of the features introduced by .NET. They are somewhat similar to objects and classes because they have methods and properties associated with them.

However, extended records are not objects in the true sense because they do not support inheritance and polymorphism.

There are other notable differences between extended records and objects as well. You cannot have constructors and destructors in extended records, and methods cannot be virtual or abstract. Additionally, any class methods in extended records must be defined with the static keyword.

Defining an extended record

Extended records are defined much the same way as regular records in Pascal.

ExtRecord = record  
  myVar : integer;  
  function foo(flag: Boolean): Integer;  
end;  

You can have visibility specifiers and properties in extended records, as follows:

ExtRecord = record  
private  
  a,b : integer;  
public  
  procedure setA(val : integer);  
  property SafeA : Integer Read A Write SetA;  
end;

Extended records support enumerators, and operators can also be defined on them.

RELATED TAGS

pascal

CONTRIBUTOR

Muhammad Ashir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring