Reference

Posts 1–4 of 4 · Page 1 of 1
Reference
So i just finished my chapter on references. But i dont see when id need to edit a target with a referece.

examples of usfulness plox
References?

Do you mean
Code:
void PartyPowah(int &x, int &y)
{
   x = y * x + y / x;
}
?
I'm tired(02:30 in the morning), GAAAH I dun even know if what i wrote above is functioning code
Quote Originally Posted by Hell_Demon View Post
References?

Do you mean
Code:
void PartyPowah(int &x, int &y)
{
   x = y * x + y / x;
}
?
I'm tired(02:30 in the morning), GAAAH I dun even know if what i wrote above is functioning code
not sure, but did you mean to say: void PartyPowah(int *x, int *y)?

Because the objective would be calling the function like: partypowah(&x,&y), with the objective of changing the actual x and y without the need to return?

Like (not tested, just wrote here):

Code:
int main()
{
     int x,y;
     partypowah(&x,&y);
     cout << x << " & " << y << endl;
}
partypowah(int *x, int *y)
{
     x = 1;
     y = 2;
}
and the output would be: 1 & 2.
Not sure if that was what u meant HD or if about this that the OP is talking about xD sry if wrong. Neither sure if this is totally correct, but i think this was the way i got used to do.
References as in
[php]int &aReference = referenceTarget;[/php]
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us