我有以下代碼:// 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 回答
- 0 關注
- 246 瀏覽
添加回答
舉報
0/150
提交
取消