3 ms·
You are correct that C also does not have pass-by-reference. However, the second listing is a C++ program, not a C program, and C++ very much has pass-by-refere
by lvh 10y ago
You are correct that C also does not have pass-by-reference. However, the second listing is a C++ program, not a C program, and C++ very much has pass-by-reference. The C++ program demonstrates true aliases, as you can tell from the output of the printf (see comment on same line).
- htns 10y agoI have always found that is conflating the semantics of using with the method of passing. Even with/out aliases you are still passing a reference.
- lvh 10y agoI don't think that's accurate. I can pass something locally declared as int to a fn that takes int& according to it's signature. It seems that's precisely what the confusion is about :)