Smarter Records in Turbo Delphi / Delphi 2006
type
TTurboRecord = record
strict private
fNameValue : integer;
function GetName: string;
public
NamePrefix : string;
constructor Create(const initNameValue : integer) ;
property Name : string read GetName;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TTurboRecord.Create(const initNameValue : integer) ;
begin
fNameValue := initNameValue;
NamePrefix := '"record constructor"';
end;
function TTurboRecord.GetName: string;
begin
Inc(fNameValue) ;
result := Format('%s %d',[NamePrefix, fNameValue]) ;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
turboRecord : TTurboRecord;
anotherTurboRecord : TTurboRecord;
begin
//no Constructor needed - fNameValue = 0 by default
turboRecord.NamePrefix := 'turboRecord';
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//constructor used
turboRecord := TTurboRecord.Create(2006) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
anotherTurboRecord := turboRecord;
anotherTurboRecord.NamePrefix := 'anotherTurboRecord';
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//NO need to FREE record types
end;
Records can have constructor, with at least one parameter.
Records support properties and static methods.
Records support operator overloading.
Records can have methods (functions, procedures).
Records do NOT support virtual methods ("virtual", "dynamic", and "message")
Records do NOT support destructors.
Ïà¹ØÎĵµ£º
Ò»¡¢DelphiÖÐÁ÷µÄ»ù±¾¸ÅÄî¼°º¯ÊýÉùÃ÷
ÔÚDelphiÖÐ,ËùÓÐÁ÷¶ÔÏóµÄ»ùÀàΪTStreamÀà,ÆäÖж¨ÒåÁËËùÓÐÁ÷µÄ¹²Í¬ÊôÐԺͷ½·¨¡£ TStreamÀàÖж¨ÒåµÄÊôÐÔ½éÉÜÈçÏÂ: 1¡¢Size:´ËÊôÐÔÒÔ×Ö½Ú·µ»ØÁ÷ÖÐÊý¾Ý´óС¡£ 2¡¢Position:´ËÊôÐÔ¿ØÖÆÁ÷ÖдæÈ¡Ö¸ÕëµÄλÖᣠTstreamÖж¨ÒåµÄÐé·½·¨ÓÐËĸö: 1¡¢Read:´Ë·½·¨ÊµÏÖ½«Êý¾Ý´ÓÁ÷ÖжÁ³ö¡£º¯ÊýÔÐÎΪ: ......
community.csdn.net/Expert/topic/3423/3423580.xml?temp=.7675897
Ö÷¡¡¡¡Ì⣺ ÔõÑùÓÃDELPHI½ÓÊÕÉãÏñÍ·µÄͼÏó
×÷¡¡¡¡Õߣº benbenpear (±¿±¿)
µÈ¡¡¡¡¼¶£º
ÐÅ Óþ Öµ£º 100
ËùÊôÉçÇø£º Delphi GAME£¬Í¼Ðδ¦Àí/¶àýÌå
ÎÊÌâµãÊý£º 0 ......
Ò»¡¢¸ÅÊö¼°Ê¾Àý´úÂë
DelphiÖаüÀ¨Ðí¶àÒѾ·â×°ºÃµÄÀ༰¿Ø¼þ£¬ÆäÖеķǿÉÊÓ»¯¿Ø¼þ¿âÒÔ¹¦ÄÜ·½Ê½»®·Ö¿É´¦ÀíÖî¶àÓ¦ÓÃÐèÇó¡£ÈôʹÓÃC£«£«ÊµÏÖϵͳʱ¶ÔijЩ¹¦Äܼòµ¥µ÷ÓÃdelphiÖÐÏֳɵĿâʱ¼´¿É¡£Òò´Ë½«delphiÖеĿâÒÔDLLÐÎʽ·â×°ºÃÖ®ºóÈçºÎ½«·½·¨µ¼³ö¿É¹©C£«£«µ÷ÓÃÊDZ¾ÎļǼµÄÖØµã¡£C£«£«µ÷Óõķ½Ê½ÓжàÖÖ£¬ÔÚÕâÀïÖ»ÌÖÂÛÒ»ÖÖ¾² ......
ÓÃDelphi×÷µÄ³ÌÐòµÄÔ´´úÂëÖг£¼ûµÄÎļþÀ©Õ¹Ãû£¬²¢¸ø³öÁËÕâЩÎļþÀ©Õ¹ÃûµÄÒâÒ壬ÒÔ±ãÔ´´úÂë¹ÜÀíʱ×÷Ϊ²ÎÕÕ£¬À©Õ¹ÃûÒÔ×ÖĸΪÐò£¨²»ÐèÒª½øÔ´´úÂë¿â²»±íʾ²»ÐèÒª½ø¿â£©¡£
¡¡¡¡~*
¡¡¡¡DelphiÉú³ÉµÄ±¸·ÝÎļþ£¬ÔÚ°æ±¾¿ØÖƿ⼰·¢²¼´úÂëÖв»Ó¦¸Ã³öÏÖÕâЩÎļþ£¬Èç¹ûÐÞ¸ÄÁËij¸öÎļþÈ´ÒòijЩÔÒòûÓб£´æµÄ»°£¬¿ÉÒÔ³¢ÊÔʹÓÃÕâЩÎļþ» ......