Almost what I was going for. I'd use a reference instead of a pointer.
Code:
void NumPlus(int& n)
{
cout<<n<<"\n";
++n; // No real difference in this case.
// I just like ++n better than n++.
}
int main()
{
int num;
for(int i=0; i<10; i++)
NumPlus(num);
}
Also note that you have a bit of a bug:
Code:
void NumPlus(int *n)
{
cout<<n<<"\n";
n++;
}
All you do is increment the pointer (which is not carried over). What you want is:
Code:
void NumPlus(int *n)
{
cout<<n<<"\n";
(*n)++;
}
or
Code:
void NumPlus(int *n)
{
cout<<n<<"\n";
++*n;
}
*edit*
I just realized that I completely misinterpreted your original question, so none of this is relevant anyway.