标签:href pre int ring main pac mys struct code
package main
import "fmt"
type Person struct {
name string
sex string
age int
}
type Student struct {
Person
id int
addr string
}
func main() {
s1:=Student{Person{"Simi","man",20}, 1, "china"}
fmt.Print(s1)
s2:=Student{Person:Person{"alex","woman",30}}
fmt.Print(s2)
s3 := Student{Person:Person{name:"wming"}}
fmt.Println(s3)
}
package main
import "fmt"
type Person struct {
name string
age int
sex string
}
type mystr string
type Student struct {
*Person
int
mystr
}
func main() {
s1:=Student{&Person{"xujk",20,"man"},22,"hello world"}
fmt.Println(s1)
fmt.Println(s1.name)
fmt.Println(s1.Person.name)
}
{0xc000066180 22 hello world}
xujk
xujk
标签:href pre int ring main pac mys struct code
原文地址:https://www.cnblogs.com/xujunkai/p/13341629.html