we declare set stl —> set s; ///// and we pass it in a function like //// func(s); //// and we receive it as reference //// void func(set &s) //// My question is how do we use ‘&’ while receiving it. I learnt that we use ‘*’ (asterisk) for receiving a pointer variable but here we used ‘&’ , WHY?
Set STL query regarding pass by reference
& acts as a refrence or another name to a particular thing.Its like giving another name to the set s, the memory allocated and all other things are same.
Hence,any changes made inside the function shows outside as well.
For accessing the set inside function, you can access it normally ie.it is same as the case without &