Pascal - 如何从 class 中的函数 return 一个 class 的数组?
Pascal - how can I return an array of a class from a function in that class?
如果我有一个 class 有一个受保护的 属性 那是一个 class 的数组和一个 public 函数来获取那个数组和 return 它 - 我如何声明它以便它允许数组作为 return 值?
通常我会使用
TNodeArray = array of Node
方法,但这在这里行不通。这就是我正在尝试的:
Node = class
protected
Neighbours : array of Node;
public
function GetNeighbours() : array of Node; //This is the problem line
end;
感谢收到任何帮助!谢谢!
将数组类型用作函数的参数或结果值的方法是使用不同的类型声明:
TNodeArray
这里还必须转发声明Node
class才能解决循环引用
Type
Node = class; // Forward declaration of the class
TNodeArray = array of Node;
Node = class
protected
Neighbours : TNodeArray;
public
function GetNeighbours() : TNodeArray;
end;
如果我有一个 class 有一个受保护的 属性 那是一个 class 的数组和一个 public 函数来获取那个数组和 return 它 - 我如何声明它以便它允许数组作为 return 值?
通常我会使用
TNodeArray = array of Node
方法,但这在这里行不通。这就是我正在尝试的:
Node = class
protected
Neighbours : array of Node;
public
function GetNeighbours() : array of Node; //This is the problem line
end;
感谢收到任何帮助!谢谢!
将数组类型用作函数的参数或结果值的方法是使用不同的类型声明:
TNodeArray
这里还必须转发声明Node
class才能解决循环引用
Type
Node = class; // Forward declaration of the class
TNodeArray = array of Node;
Node = class
protected
Neighbours : TNodeArray;
public
function GetNeighbours() : TNodeArray;
end;