so, i have a main method
int main () {
int x = 0;
inc(x);
inc(x);
inc(x);
std::cout << x << std::endl;
}
I'm trying to get my output to be '3' but can't figure out why everytime inc(x) is called x resets to 0.
my inc method:
int inc(int x){
++x;
std::cout << "x = " << x << std::endl;
return x;
}
my output:
x = 1
x = 1
x = 1
0
Why does x reset after every call to inc(x) and how can i fix this without editing my main function