下面代码输出什么?
package main
import "fmt"
type A interface {
ShowA() int
}
type B interface {
ShowB() int
}
type Work struct {
i int
}
func (w Work) ShowA() int {
return w.i + 10
}
func (w Work) ShowB() int {
return w.i + 20
}
func main() {
c := Work{3}
var a A = c
var b B = c
fmt.Println(a.ShowB())
fmt.Println(b.ShowA())
}
- A. 23 13
- B. compilation error
B 在线运行
A接口没有ShowB方法 B接口没有ShowA方法