package main
import "fmt"
// 指针
// 区别于c/c++ Go语言指针不能进行偏移和运算 是安全指针
// 指针地址
// 指针类似
// 指针取值
// & 取地址 * 根据地址取值
// 指针传值例子
func mod1(x int) {
x = 100
}
func mod2(x *int) {
*x = 100
}
func modArry(a1 *[3]int) {
a1[0] = 20
}
// new 内置函数 接收一个类型参数 返回指向该类型的内存地址的指针
// func new(Type) *Type {
// }
// 得到一个int类型的指针
// var a = new(int)
// make 返回类型本身
// func make(t Type, size ...IntergerType) Type {
// }
func main() {
// a := 10
// b := &a
// fmt.Printf("a: %d ptr: %p\n", a, &a)
// fmt.Printf("b: %p type: %T\n", b, b)
// print(&b)
// print(*b)
a := 20
mod1(a)
fmt.Println(a)
mod2(&a)
fmt.Println(a)
a2 := [3]int{1, 2, 3}
modArry(&a2)
fmt.Println(a2)
}