+ 2

Why we use pointer in swapping??

We can swap without pointer but still we use pointer why???

28th Jul 2017, 6:04 AM
Gauri
Gauri - avatar
4 Respuestas
+ 1
Pointer are used when the values are passed to function and then swapped. Or normal swapping can be done.
28th Jul 2017, 6:19 AM
G.S.N.V. Suraj
G.S.N.V. Suraj - avatar
+ 7
There is no particular reason to do swapping with pointers. You can also pass by reference to functions for swapping purposes. Pointers are simply there as an alternative method for stuff.
28th Jul 2017, 6:36 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
References are hidden pointers, when I said pointers, I included references ^^'
28th Jul 2017, 6:37 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
We can swap without pointer if you do not create a function. With a function you must (at least to do it properly).
28th Jul 2017, 6:29 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar