声明
type
TMyGrid=class(TCustomGrid);
然后调用
TMyGrid(StringGrid1).MoveRow(***);
为什么这样用才行?
而TCustomGrid(StringGrid1).MoveRow(***);不行呢?
type
TMyGrid=class(TCustomGrid);
然后调用
TMyGrid(StringGrid1).MoveRow(***);
为什么这样用才行?
而TCustomGrid(StringGrid1).MoveRow(***);不行呢?
另外我想问一下
type
T1 = class(TObject)
procedure Act(i:integer); virtual;
end;
T2 = class(T1)
procedure Act(i:string);overload;
end;
var
MyT1:T1;
MyT2:T2;
MyT1和T1(MyT2)有什么区别?如果去掉收保护的成员的话
我得qq是214114996,那位大哥能帮帮忙,加我进去,希望能指点指点在下,不胜感激,因为好多问题说不出来阿,拜托各位了.
对于TCustomGrid
定义如下:
TCustomGrid = class(TCustomControl)
private
......
protected
......
procedure MoveRow(FromIndex, ToIndex: Longint);
procedure RowMoved(FromIndex, ToIndex: Longint); dynamic;
......
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function MouseCoord(X, Y: Integer): TGridCoord;
published
property TabStop default True;
end;
type
T1 = class(TObject)
protected
procedure MyPro();
end;
T2 = class(T1)
end;
var
var
SomeObject: T2;
begin
SomeObject := T2.Create;
T1(SomeObject).MyPro;
SomeObject.Free;
end;procedure T1.MyPro();
begin
showmessage('this is a protected method');
end;
这样可以编译通过阿,为什么?
收保护的方法(protected)除了在声明的类中使用以外,还可以在派生类中使用,在c++中,只能从派生类内部调用,在外部是不允许的.就是适用于类本身,而不是类对象,delphi应该也是这样吗?