Golang学习笔记(六):struct
struct
struct,一组字段的集合,类似其他语言的class
放弃了大量包括继承在内的面向对象特性,只保留了组合(composition)这个最基础的特性
1.声明及初始化
typepersonstruct{
namestring
age int
}
//初始化
funcmain(){ varPperson
P.name="tom" P.age=25 fmt.Println(P.name)
P1:=person{"Tom1",25} fmt.Println(P1.name)
P2:=person{age:24,name:"Tom"} fmt.Println(P2.name) }
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短