go指针与C++指针用法不同,按哪个语言的用法用指针,请问如何抉择?

taatcc · · 1292 次点击
go的指针应该不会像c++那种,容易崩溃程序吧,go规避了指针的一些容易犯的错误,比c++好多了
#6
更多评论
在官方的[effective go](https://golang.org/doc/effective_go.html#composite_literals)中有一句话 > Note that, unlike in C, it's perfectly OK to return the address of a local variable; the storage associated with the variable survives after the function returns. 所以在 go 中,返回指向局部变量的指针是没问题的。
#1
这样的话,写go和c++,要切换思维模式,挺不习惯的
#2