// testStruct project main.go
package main
import (
    "fmt"
)
type A struct {
    Text string
}
type Operator interface {
    Say()
}
func (a *A) Say() {
    fmt.Printf("A::Say():%s\n", a.Text)
}
type B struct {
    A
}
func (b *B) Say() {
    b.A.Say()
    fmt.Printf("B::Say():%s\n", b.Text)
}
func main() {
    b := B{}
    b.Text = "hello,world"
    b.Say()
}

A::Say():hello,world

B::Say():hello,world

版权声明:本文为博主原创文章,未经博主允许不得转载。


有疑问加站长微信联系(非本文作者)