Both of these functions rewrites the original value right? Is there any benefit to doing it one way over the other?
#include <iostream>
using namespace std;
void passptr(int *p)
{
*p = 7;
}
void passaddy(int &a)
{
a = 7;
}
int main()
{
int a = 5;
int *p = &a;
passptr(p);
cout << a << endl;
a = 5;
passaddy(a);
cout << a << endl;
return 0;
}