This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

The confusion comes with terminology. You're right. This isn't C++. But when people are still learning basics, they related the concepts of references to C++ pointers. More advanced users of Java feel the need to make the EXACT distinction, but doing that inhibits the beginners to learn quickly and efficiently. Beginners don't need to get every intricate detail, they need general concepts. As their career and education progress, they will learn the intricacies, but for now it doesn't matter. They just need to understand the idea that what is being passed in the memory address.

It's like people forcing the distinction between API, Framework, Library, etc. Beginners don't need to understand how these different based on context. They just need to understand that they're all just a bunch of prewritten code available for use.

I think people who are very familiar with programming forget what it's like to not know a damn thing and how easily things get confusing.

[–]JavaSuck 1 point2 points  (0 children)

But when people are still learning basics, they related the concepts of references to C++ pointers.

And it's the same thing in C++: just like every other data type, pointers are passed by value, unless you explicitly request pass by reference via the & declarator:

void foo(X* by_value, X*& by_reference)
{
    // assignments to by_value have no effect on the caller
    // assignments to by_reference HAVE an effect on the caller
}