富
富翁中的穷人
Unregistered / Unconfirmed
GUEST, unregistred user!
我的对象需要从多个对象继承,这个通过一般的父类解决有点麻烦,于是我想用类中再定义类型也是类的成员解决,例如:作为一个儿子,有父亲和母亲分别是Tson,TFather,Tmother要执行的操作是: son:=Tson.Create
son.Father.Name:='ABC'
// ==>出错 Son.Mother.Name:='DEF';到第2句就出错了。类定义如下:TFather=Class private _Name:string
published property Name:string Read _Name Write _Name
end
TMother=Class private _Name:string
published property Name:string Read _Name Write _Name
end
TSon=class Private _Name:string
_Father:TFather
_Mother:TMother
published property Name:string Read _Name Write _Name
property Father:TFather Read _Father Write _Father
property Mother:TMother Read _Mother Write _Mother
end;
son.Father.Name:='ABC'
// ==>出错 Son.Mother.Name:='DEF';到第2句就出错了。类定义如下:TFather=Class private _Name:string
published property Name:string Read _Name Write _Name
end
TMother=Class private _Name:string
published property Name:string Read _Name Write _Name
end
TSon=class Private _Name:string
_Father:TFather
_Mother:TMother
published property Name:string Read _Name Write _Name
property Father:TFather Read _Father Write _Father
property Mother:TMother Read _Mother Write _Mother
end;