I would like to know difference between the following 2 functions
void fun1(vector<int>&v){
v.push(1);
fun1(v);
}
void fun2(int *sum)
{
x=2;
new_sum=*sum+x;
fun2(&new_sum);
}
I am unable to understand difference. In first function, function declaration has use of pointer and no other place in function body has '&' symbol. In function 2, function declaration has value at address pointer and function body has '&'. Please explain
like here in below function we use &diagonalsum for passing map why it is used?
void diagonalSumUtil(struct Node* root,
int vd, map<int, int> &diagonalSum)
{
if(!root)
return;
diagonalSum[vd] += root->data;
// increase the vertical distance if left child
diagonalSumUtil(root->left, vd + 1, diagonalSum);
// vertical distance remains same for right child
diagonalSumUtil(root->right, vd, diagonalSum);
}