I have a question that why to pass vector or string by reference. simply why to pass a value by reference? let's take a example :- suppose I want pass a vector in function then I'd write below code:-
void fun(vector<string/int>v){
......
......
}
so sometime it gives correct output but sometime it gives wrong.
but when I use:-
void fun(vector<string/int> & v){
......
......
}
then wrong output turns right so tell me when to use & and why ?
thank u in advance...