Questions about the different Scopes/Visibilities of variables in a Delphi Unit -
lets have delphi unit:
unit unit1; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, vcl.stdctrls, vcl.extctrls; type tform1 = class(tform) private { private-deklarationen } public { public-deklarationen } end; var form1: tform1; implementation {$r *.dfm} var nummer:integer;
i understood there public interface-section , private implementation-section.
functions , procedures defined in public-section can used ohter units.
functions , procedures defined in private-section can used in unit.
but variables after var
in interface-section global variables? if yes there difference global variables in public? , difference between variables defined after implementation , ones under private?
- the variables after var in interface section become accessible use global in unit 'uses' unit.
- the vars defined outside of class have 1 value shared across instances of class, changing variable in 1 object call affect variable objects of class type. if define var inside class definition, each object have own version of variable.
Comments
Post a Comment