- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关于德尔福构造函数的一系列问题中的另一个问题。
我有一个具有虚拟构造函数的基类:
TComputer = class(TObject)
public
constructor Create(Teapot: Integer); virtual;
end;
var
computerClass: class of TComputer;
computer: TComputer;
begin
computer := computerClass.Create(nTeapot);
overridden
:
TCellPhone = class(TComputer)
public
constructor Create(Teapot: Integer); override;
end;
TiPhone = class(TCellPhone )
public
constructor Create(Teapot: Integer); override;
end;
TCellPhone
和
TiPhone
子孙各自都有机会进行自己的初始化(出于可读性考虑,不包括这些成员)。
TCellPhone = class(TComputer)
public
constructor Create(Teapot: Integer); override; overload;
constructor Create(Teapot: Integer; Handle: string); overload;
end;
constructor TCellPhone.Create(Teapot: Integer; Handle: string);
begin
TCellPhone.Create(Teapot); //call sibling virtual constructor
FHandle := Handle;
end;
phone := TiPhone.Create(37, 'spout')
constructor TCellPhone.Create(Teapot: Integer; Handle: string)
constructor TCellPhone.Create(Teapot: Integer)
constructor TComputer.Create(Teapot: Integer)
TObject.Create
TCellPhone.Create(int)
的同级调用是虚拟的,应该在
TiPhone
中调用后代,重写的方法:
phone := TiPhone.Create(37, 'spout')
constructor TCellPhone.Create(Teapot: Integer; Handle: string)
constructor TiPhone.Create(Teapot: Integer)
constructor TCellPhone.Create(Teapot: Integer)
constructor TComputer.Create(Teapot: Integer)
TObject.Create
public Bitmap(int width, int height) : this(width, height, PixelFormat.Format32bppArgb) {}
public Bitmap(int width, int height, PixelFormat format) {...}
最佳答案
错误..
应该是:
constructor TCellPhone.Create(Teapot: Integer; Handle: string);
begin
TCellPhone.Create(Teapot); //call sibling virtual constructor
FHandle := Handle;
end;
关于delphi - Delphi:重载不会调用重写的虚拟构造函数后代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3892258/
我有一个表(id, parent_id, data),其中parent_id 指向同一表中的另一行(或者为空)。 是否有一种标准的方法来查询(1)某个 id 的所有祖先和(2)某个 id 的所有后代?
networkx 中是否有函数/方法来识别给定(可选加权)距离内的所有祖先/后代? 例如,可以有效地产生与下面的函数相同的结果的东西? import networkx g = networkx.DiG
在我的窗口事件中,如果指针点击父对象或其子对象/后代对象,它应该做一些事情。问题是事件无法访问 parent 的 child 和孙子。条件存储在 targetIsInsideParent 变量中。 H
我有一个非常好的 DirectMySQL 单元,可以使用,我希望它成为 TDataset 的后代,这样我就可以将它与 QuickReport 一起使用,我只想要使用来自 TDataset 的 Dire
我将 mysql 表定义为: 类别:category_id、category_name、parent_category_id 我正在寻找一个很好的 sql 查询来检索给定 category_id 的所
我的 TCustomControl 后代使用线程,这涉及使用 InvalidateRect 进行无效化。我遇到这样的情况:当线程正在工作时关闭程序时,我不会停止 Destroy 中的线程,因为即使在进
我的 TMemo 后代有构造函数 constructor TMyMemo.Create(AOwner: TComponent); begin inherited Create(AOwner);
我正在尝试创建一个像Delphi 2009的TButtonedEdit这样的组件。它是一个自定义的TEdit,左右各有2个按钮。 在我的版本中,我使用 2 个 TSpeedButton 对象作为左右按
我遇到了一些问题,看起来使用 JQuery 应该很容易做到。基本上我的页面上有一个表格。表格中的每一行都有一个复选框和一个金额单元格。我正在尝试编写一个函数来遍历每一行并检查复选框是否已选中。如果是这
如何使用 linq 对包含相同对象的子集合 X 层深的对象集合获得与 doc.Descendants() 类似的功能? 最后一个嵌套集合包含需要获取的数据,所有其他父集合只是分组。我可以将集合转换为
我有一个引用自身的表,如下所示: CREATE TABLE Foo ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, parent INT NULL, nam
我正在尝试添加以下约束来对齐表格单元格内的图像。 self 指的是 ImageView 将驻留在其中的 UITableViewCell 对象: var imageViewTest = UIIm
我有以下标记: content Link Link Link
这里是一个简化的mxl结构'xml', Alice30 Bob31 Charley29 Dory25 这是我尝试过的; XmlDocument submiss
我正在尝试编写一个类,该类将在其对象创建时运行一个线程,并在对象被删除后停止该线程。 class MyThread : public boost::thread { public: MyThr
我有一个表 width: 100%以及该表中的元素 width: 40em; max-width: 100% , 但当浏览器窗口太小时,该元素仍在拉伸(stretch)表格。 我希望这个元素的宽度固定
我正在尝试在 Delphi 2007 中创建基于 TCustomComboBox 的自定义控件,但我陷入了第一个障碍。 我试图覆盖下拉列表的显示方式,主要是显示的文本,查看 stdctrls.pas
我正在尝试创建一个具有集合属性的自定义组件。但是,如果我尝试在设计时通过单击对象检查器中的“...”按钮来打开集合编辑器,则不会发生任何情况。我缺少什么? 这是我的 TCollection 后代:
我正在使用WPF DataGrid,并放置了DataGridTemplateColumn。因为该列应该对复杂类型(这是一个对象)执行编辑,所以我决定放置一个打开弹出窗口的切换按钮。代码如下:
我有一个基本的 UserControl (BaseControl.cs),上面有一个 OK 和 Cancel 按钮。单击按钮时,将触发一个事件。通常其他 UserControl 对象继承自 BaseC
我是一名优秀的程序员,十分优秀!