in dfs_helper we have argumented visited by &visited, and when we pass array or any other thing we pass it by *arr. sir, i m confused in when to use & and when to use *.pls help
Ragarding & and *
@aman17nov1999 hey & refer to reference operator in C++,if you use & operator than it will alaso make change in original adress of variable and you can use them simply like variable:eg:
dfs(int & v)
{
v++;
}
in main call this dfs(v);
now this dfs will make change in original v and you can use v in function just like normal variable
Another is pointer so you can also use pointer but have to pass address while calling like this dfs(&v) ,for more information use this link:
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.