我有以下代码:// eventloop.gotype Object interface { ActivateSlot(name string, parameters vector.Vector);}// main.goimport loop "./eventloop"// ...const slotname = "printer"type printer struct { slot loop.Slot;}func (p *printer) Init() { p.slot = loop.Slot{slotname, p}; // offending line}func (p *printer) ActivateSlot(name string, parameters vector.Vector) { fmt.Println("Slot called: ", name); }当我尝试编译时,出现以下错误:jurily@jurily ~/workspace/go $ ./build.shmain.go:23: cannot use p (type *printer) as type *eventloop.Object in field value如果我将有问题的行注释掉,它可以编译并运行良好。这里发生了什么事?我想念什么?
1 回答
- 1 回答
- 0 关注
- 247 浏览
添加回答
举报
0/150
提交
取消