[fpc-pascal] Re: variables in class, class variables and fields
Paul Ishenin
webpirat at mail.ru
Sat Nov 6 16:38:21 CET 2010
06.11.2010 22:16, ik wrote:
> why not something like this:
>
> TAClass = class
> private
> FField : class integer;
> end;
"var" and "class var" starts new sections in the class declaration.
Therefore you can define several class fields or instance fields after them.
For example
TAClass = class
private
class var
Field1: Integer;
Field2: String;
var
Field3: Integer;
Field4: String;
end;
> Further more, what is the difference between a "normal" field and a
> variable inside a class:
>
> TAClass = class
> private
> var Variable : Integer;
> end;
var - you start a fields section
Variable : Integer; - you declare a field inside this section.
You can skip "var" in this case. But if you previosly had "const" or
"type" section or had a method/property declaration and want to declare
a field again then you need to explicitly start a field section by "var"
keyword.
For example:
TAClass = class
private
type
TMyInt = type integer;
var // this keyword is required here
Field1: TMyInt;
end;
Best regards,
Paul Ishenin.
More information about the fpc-pascal
mailing list