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

taatcc · · 1292 次点击
说的也是,go这种方式规避了c++造成了指针风险,应该是有好处的,在go中用指针确实放心多了,不怎么出错
#4
更多评论
在官方的[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