Code:
// passing parameters by reference
#include <iostream>
using namespace std;
void duplicate (int& a, int& b, int& c)
{
a*=2;
b*=2;
c*=2;
}
int main ()
{
int x=1, y=3, z=7;
duplicate (x, y, z);
cout << "x=" << x << ", y=" << y << ", z=" << z;
return 0;
}
my confusion comes when you get to a*=2;. I know what the code does when you compile it, but im afraid i dont understand exactly why its written like that. it has me very confused.
basically what it looks like to me is
"a[int] times equals 2"
which as you can see, dosent make a lick of sense.
can someone break it down for me, and tell me why its written this way? the tutorials im reading dont explain what im asking. hopefully you understand what it is im asking.
Thanks in advance!