不知道考该证要看哪些书籍?help^^^
先给你出道题吧!
面向对象(覆盖与改写(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=___________