1234567891011121314151617 |
- package model
- import "fmt"
- //继承
- type People struct {
- name string
- age int
- }
- type Teacher struct {
- People
- classroom string
- }
- func main() {
- tea := Teacher{People{"derek", 22}, "911"}
- fmt.Println(tea.classroom, tea.name, tea.age) //911 derek 22
- }
|