gpt4 book ai didi

delphi - 我可以在 Delphi 中为我自己的类重载运算符吗?

转载 作者:行者123 更新时间:2023-12-03 18:54:27 26 4
gpt4 key购买 nike

我遇到了一点麻烦——我不知道我是否可以为我的类定义自己的运算符。
例如:

type
TMinMatrix = class(TMatrix)
private
RowAmount: Byte;
ColAmount: Byte;
Data: DataMatrix;
DemVector, SupVector: SupplyDemand;
public
constructor Create(Rows, Cols: Byte);
function GetRowAmount: Byte; override;
function GetColAmount: Byte; override;
destructor Destroy;
end;

我怎么能 - 或者我不能:) - 做类似的事情:
TMinMatrix TMinMatrix::operator=(TMinMatrix* matr)    (c++ code)

而且,顺便说一句,我可以为我的类定义复制构造函数吗?

最佳答案

Delphi Win32 2007 和 2009 仅支持记录的类运算符重载,可以有隐式和显式运算符。
Delphi .Net 支持记录和类的类操作符。

关于delphi - 我可以在 Delphi 中为我自己的类重载运算符吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/329359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com