If i have the following methods:
void addfive(int num)
{
num = num + 5;
}
and when i use it in the main routine like this:
int a = 15;
addfive(a);
What will happen is that 5 will be added to a copy of the (a) variable.
but if the method parameter is a pointer int* num
instead of the int num
5
will be added to the (a) variable and no copy is created.
If I used the pointer in my method, will this use less memory that the first method, and will this work in non_void methods?