A function that modifies more than one value

Hello all, i've posted this before but noone replied, so i'll ask again:

i need a function that scales all of its arguments with a constant (or does a random thing to its arguments). Then i need to update my arguments...
How can i possible do that
EG.
1
2
3
4
5
6
int scale(int a, int b, int c)
{
  a *= 4;
  b *= 4;
  c *= 4;
}


Thanks for any suggestions.

Your question is hard to understand but, you will need to pass the variables by reference or pointer.
pass a reference or pointer to a struct or class.
do it like this:

1
2
3
4
5
6
int scale(int & a, int & b, int & c)
{
  a *= 4;
  b *= 4;
  c *= 4;
}


for more information about passing arguments by reference (the '&' symbol) check this:
http://www.cplusplus.com/doc/tutorial/functions2/
(it even has an example very similar to what you want to do)

another topic where this matter is discussed and you might find helpful is this:
http://www.cplusplus.com/forum/beginner/21874/
Last edited on
Topic archived. No new replies allowed.