what happens internally in the below function call

Hi all,

int func(int&a,int&b)
{
//some statements
}

int main()
{
int a=10,b=20;
func(a,b); //what happens intrnally in the memory during this call?
}
It's difficult to say with certainty because of, among other things, the optimizations the compiler may perform.
What do you want to know specifically?
in call by value an extra variable is created and the value is copied and then the func call takes
place
in call by reference(pointer) the address is copied then func call takes place.

similarly in the func definition if we use refernce as arguements rather than values or pointers
how this gonna be some memory effiicient?
As I said, that depends on the optimizations the compiler may perform. In any case, the space cost of function parameters can be safely assumed to be zero for 99.99% of all functions.
Don't worry about it, just use whatever is most convenient to you.
Last edited on
Topic archived. No new replies allowed.