0

What is the difference between passing variables to C++ function using

1) pass by reference with a pointer 2) pass by reference using a reference

6th Mar 2018, 5:11 AM
Mansi Saini
Mansi Saini - avatar
2 ответов
0
You can only pass a c++ object via pointer if I remember it correctly. If you pass a pointer, you directly work with an adress which should have the effect that the changes persist outside the function as well.
6th Mar 2018, 6:32 AM
Kai Schlegel
Kai Schlegel - avatar
0
It's mostly the same, except for abstraction​. For the reference, inside the function you use normal variable Syntax instead of pointer Syntax. Also you can't change the address of a reference, so I would only use for an object, not an array.
6th Mar 2018, 9:26 AM
Jared Bird
Jared Bird - avatar