CLASS
is a structured data type in Object Pascal. Which are able to contain variables, functions, procedures like a record, however a class uses access scopes, allowing one object to inherit variables and methods from another - saving on design time.
type vehicle = class doors:byte; seats:byte; function availableColors:TStringArray; end;Now depending upon the type of manufacturer, these could be street vehicles and have the following descendant classes that inherit those 3 elements:
type car = class(vehicle) // <-- so a car inherits everything from vehicle. engineType:avalableCarEngines; sportsPackage:Boolean; end; truck = class(vehicle) engineType:availableTruckEngines; offRoadPackage; end;There is more code needed to instantiate the classes into objects in memory, we are keeping this brief to show the conceptual benefit of a class.
var MyAuto:car; Begin MyAuto.Init; MyAuto.Doors:=2; MyAuto.Seats:=4; MyAuto.engineType:=CarV8; MyAuto.SportsPackage:=True; {... more code here ...} MyAuto.Free; End.Source: Reserved Words