如何在其他类中访问基类成员变量

时间:2013-08-19 12:35:35

标签: delphi

为了简化我的问题,我引用了一个像这样的课程

Base = class;
public:
 Name: String;
end;

Derived = class(Base)
public:
 Name: String;
end;


Procedure Book.DoSomething;
Var
str: String;
Begin
 str := derivObj.Name; //I need base class Name not the Derived one
End;

我对Delphi非常陌生,所以请帮帮我。

1 个答案:

答案 0 :(得分:4)

要访问父类成员:     str:= Base(derivObj).Name;