Hi - I don't know C++ and am confused reading some C++ code (for learning):
In the following code, the way the function takes the address of int a, and doubles it, seems weird; in C shouldn't we pass &a to the function and then dereference with *x *= 2 ??
Or is that a typo in the C++ code I am reading?
In the following code, the way the function takes the address of int a, and doubles it, seems weird; in C shouldn't we pass &a to the function and then dereference with *x *= 2 ??
Or is that a typo in the C++ code I am reading?
Code:
void MyFunction (int &x)
{ x *= 2;
}
...
int main()
{
int a = 4;
MyFunction (a);
...