【发布时间】:2021-02-19 19:04:14
【问题描述】:
type top struct {
node *tree
hd int
}
func (t *bt) topview() {
if t.root == nil {
return
}
qu := list.New()
qu.PushBack(top{t.root, 0})
sample := qu.Front()
fmt.Println(sample.hd)```
失败,错误 sample.hd undefined (type *list.Element has no field or method hd)
【问题讨论】:
-
虽然您可以使用列表实现队列,但切片可能更合适 - 请参阅 this answer 了解更多信息。