Files
the-way-to-go_ZH_CN/eBook/examples/chapter_10/embedd_struct.go

19 lines
195 B
Go

package main
import "fmt"
type A struct {
ax, ay int
}
type B struct {
A
bx, by float32
}
func main() {
b := B{A{1, 2}, 3.0, 4.0}
fmt.Println(b.ax, b.ay, b.bx, b.by)
fmt.Println(b.A)
}