-
Notifications
You must be signed in to change notification settings - Fork 0
0913new于make,以及指针与引用的区别
ziyouzy edited this page Sep 13, 2020
·
1 revision
https://www.cnblogs.com/smartrui/p/12055399.html
person1 := Person{"zhangsan","man",25} //创建一个person1对象 person2 := new(Person)//使用new创建一个person2对象,同时获得person的指针 person2.name,person2.sex,person2.age = "wangwu","man",25 person3 := &Person{"lisi","man",25}//使用&创建一个person3对象,同时获得person的指针
i,err :=testyou()
person1 := Person{"zhangsan","man",25} //创建一个person1对象 fmt.Printf("person1:%v\n",person1) demo(&person1) fmt.Printf("person1:%v\n",person1)