有两个类 一个父类 一个子类, 子继承父
A对象在申明的时候 申明为父的对象, 在构造(creat)的时候能构造成子类的对象吗?
Type
TFather=Class
A: Integer;
End;
Tson=Class(TFather)
A: string;
End;
Var
Myboject: TFather;
Begin
Mobject:=Tson.Create;//(请问这里MYobject可以这样构造吗?)
A对象在申明的时候 申明为父的对象, 在构造(creat)的时候能构造成子类的对象吗?
Type
TFather=Class
A: Integer;
End;
Tson=Class(TFather)
A: string;
End;
Var
Myboject: TFather;
Begin
Mobject:=Tson.Create;//(请问这里MYobject可以这样构造吗?)
A: Integer;
End;
Tson=Class(TFather)
A: string;
End; Var
Myboject: ^TFather;
Begin
Mobject:=Tson.Create;//
PASCAL语法不熟悉,大概意思这样
Type
TFatheer =Class
i:Integer;
End;
TSon =Class(TFather)
i:string;
End;
VAR
Myobject : TFather;
begin
Myonject :=TSon.Creat;
Myobject.i:='hello';//错误
TSon(Myobject).i:='hello';//正常
Type
TFatheer =Class
i:Integer;
End;
TSon =Class(TFather)
i:string;
End;
VAR
Myobject : TFather;
begin
Myonject :=TSon.Creat;
Myobject.i:='hello';//错误
TSon(Myobject).i:='hello';//正常