Thursday, 15 August 2013

What happens when use a function with an argument by reference with a pointer?

What happens when use a function with an argument by reference with a
pointer?

References with functions are rather confusing. You can put one in as an
argument in a function definition, then put a non-reference non-pointer
value in for the argument when you use it later. And then I thought about
this:
int foo (int& bar)
{
//Code
}
//More code...
int* a = &b;
c = foo (a);
What happens? Does foo use a, b, or what? How do I force either use?

No comments:

Post a Comment