Is there “pass by reference”(C++) in go?

馋奶兔 提交于 2021-02-16 14:57:47

问题


I am defined a function using pointer, like the following

func concat(head1, head2 *Node) Node {
}

and pass in pointer. but I am wondering if Go supports pass by reference like C++ which I could use like the following

func concat(head1, head2 &Node) Node

回答1:


The Go Programming Language Specification

Calls

In a function call, the function value and arguments are evaluated in the usual order. After they are evaluated, the parameters of the call are passed by value to the function and the called function begins execution. The return parameters of the function are passed by value back to the calling function when the function returns.


No. Parameters are passed by value.



来源:https://stackoverflow.com/questions/47340934/is-there-pass-by-referencec-in-go

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!