int thi program, why we pass is_visited by &,
if im not applying & op is incorrect,
what is the differnce in using & in fucntion calling and & in the args of function called
int thi program, why we pass is_visited by &,
if im not applying & op is incorrect,
what is the differnce in using & in fucntion calling and & in the args of function called
hello @akb.tech17,
the answer is simple, i.e pass by value and pass by reference.
if we use & that means we are passing object as reference so in this case reference of object is passed so whatever change we will make is_vis inside function it will be reflected in orginal object.
but if we pass without using & then a copy of object is passed and whather changes we will make in is_visited inside function, it will not reflected in orginal objected.
refer this article -> https://www.tutorialspoint.com/differences-between-pass-by-value-and-pass-by-reference-in-cplusplus
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.