【发布时间】:2018-03-21 05:51:08
【问题描述】:
我试图在struct 的帮助下制作一棵二叉树,如下所示:
struct BinaryTree {
var value: Int
var left: BinaryTree
var right: BinaryTree
}
但我收到错误 error: value type 'BinaryTree' cannot have a stored property that recursively contains it。
这里 struct 是值类型,所以我不能在其中创建相同的 struct 对象。
我怎样才能做到这一点???
【问题讨论】:
-
Cchanch 这里有几篇回答这个问题的帖子:stackoverflow.com/q/38191372/468724 和这个stackoverflow.com/q/40771706/468724
-
感谢您的帮助:)
标签: swift data-structures tree binary-tree