3 ms·
In C++, pass-by-reference means the method gets a reference to the thing. Pass-by-value means the method gets a copy of the thing. Do these terms mean somethin
by 16s 16y ago
In C++, pass-by-reference means the method gets a reference to the thing. Pass-by-value means the method gets a copy of the thing.
Do these terms mean something different in Java? Again, I'm not a big Java dev, but I am interested in why there's such a big debate on this topic.
In C++, I typically pass-by-reference when I need to change the thing. When I don't need to change the thing (but it's expensive to copy) I pass by const reference so the thing cannot be changed, but is still efficient.
I seldom pass-by-value unless it's a primitive type (int, char, etc.).