teacher.go 256 B

1234567891011121314151617
  1. package model
  2. import "fmt"
  3. //继承
  4. type People struct {
  5. name string
  6. age int
  7. }
  8. type Teacher struct {
  9. People
  10. classroom string
  11. }
  12. func main() {
  13. tea := Teacher{People{"derek", 22}, "911"}
  14. fmt.Println(tea.classroom, tea.name, tea.age) //911 derek 22
  15. }