Problem Add++ to function

 

I don't understand this triviality, I simply want to add a number sequence in a function but this doesn't happen and I don't understand why.

void Test(int Par_Add)
{
 Print("Add: ",IntegerToString(Par_Add));
 Par_Add++;
}

int OnInit()
{

int AddRett=0;

for(int i=0; i<30; i++)
      {

        Test(AddRett);
      } 

return(INIT_SUCCEEDED);
}

How can I pass a variable into a function and have it add up with a simple ++ ? Thanks

 

Okay you have to pass it by reference, correct?

void Test(int &Par_Add)
{
 Print("Add: ",IntegerToString(Par_Add));
 Par_Add++;
}

int OnInit()
{

int AddRett=0;

for(int i=0; i<30; i++)
      {

        Test(AddRett);
      } 

return(INIT_SUCCEEDED);
}
 
fly7680 #:

Okay you have to pass it by reference, correct?

Corretto, ricordo che questo è un forum in italiano perciò scrivete in italiano.
 
Michele Catanzaro #:
Corretto, ricordo che questo è un forum in italiano perciò scrivete in italiano.
Grazie per la risposta e la prossima olta scriverò in italiano che male non fà!!!