标题:万分火急………
只看楼主
windows17
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-3-24
 问题点数:0 回复次数:1 
万分火急………
各位大哥大姐,小弟因想今年考一个Delphi高级程序员的证书,现在苦于不知从何下手 ,恳请各位帮忙。
不知道考该证要看哪些书籍?help^^^
搜索更多相关主题的帖子: 火急 
2006-03-24 21:26
ysp_1984
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:371
专家分:0
注 册:2006-1-5
得分:0 

先给你出道题吧!

面向对象(覆盖与改写(override))
TClass1 = class(TObject)
private
FIntProp: Integer;
protected
public
procedure Add1; virtual;
procedure Add2;
property IntProp: Integer read FIntProp write FIntProp;
end;

TClass2 = class(TClass1)
private
protected
public
procedure Add1; override;
procedure Add2;
end;

procedure TClass1.Add1;
begin
FIntProp:= FIntProp + 1;
end;

procedure TClass1.Add2;
begin
Add1;
FIntProp:= FIntProp + 3;
end;

procedure TClass2.Add1;
begin
inherited Add1;
FIntProp:= FIntProp + 5;
end;

procedure TClass2.Add2;
begin
inherited Add2;
FIntProp:= FIntProp + 7;
end;

var
AObject: TClass1;
begin
AObject:= TClass2.Create;
try
AObject.IntProp:= 0;
AObject.Add1;
AObject.Add2;
Edit1.Text := IntToStr(AObject.IntProp);
finally
AObject.Free;
end;
end;

以上代码执行后,Edit.Text=___________

面向对象(覆盖与改写(override))
TClass1 = class(TObject)
private
FIntProp: Integer;
protected
public
procedure Add1; virtual;
procedure Add2;
property IntProp: Integer read FIntProp write FIntProp;
end;

TClass2 = class(TClass1)
private
protected
public
procedure Add1; override;
procedure Add2;
end;

procedure TClass1.Add1;
begin
FIntProp:= FIntProp + 1;
end;

procedure TClass1.Add2;
begin
Add1;
FIntProp:= FIntProp + 3;
end;

procedure TClass2.Add1;
begin
inherited Add1;
FIntProp:= FIntProp + 5;
end;

procedure TClass2.Add2;
begin
inherited Add2;
FIntProp:= FIntProp + 7;
end;

var
AObject: TClass1;
begin
AObject:= TClass2.Create;
try
AObject.IntProp:= 0;
AObject.Add1;
AObject.Add2;
Edit1.Text := IntToStr(AObject.IntProp);
finally
AObject.Free;
end;
end;

以上代码执行后,Edit.Text=___________


心中的那片蓝天,永远为你而存在... ...
2006-03-24 22:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-52584-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.506867 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved