初学Golang,在阅读github代码时,经常碰到struct的嵌套用法:
type person struct{
name string
age int
}
type student struct{
*person
level int
}
在student这个结构体中,嵌套了person。一直不明白,为什么person前面要加个星号?跟不加星号的写法有什么区别?
经过一番实验,
初学Golang,在阅读github代码时,经常碰到struct的嵌套用法:
type person struct{
name string
age int
}
type student struct{
*person
level int
}
在student这个结构体中,嵌套了person。一直不明白,为什么person前面要加个星号?跟不加星号的写法有什么区别?
经过一番实验,