#include<iostream>
#define LOG(x) std::cout<<x<<std::endl
void increment(int value)
{
++value;
}
int main()
{
int a = 6;
increment(a);
LOG(a);
std::cin.get();
}
I press F11 and debug into the function of "increment".The parameter of function equal to 6.But why the "value++"doesn't work .I know it is called "pass by value",but I think local value should change in the function of body.
#include<iostream>
#define LOG(x) std::cout<<x<<std::endl
void increment(int& value)
{
++value;
}
int main()
{
int a = 6;
increment(a);
LOG(a);
std::cin.get();
}
here I pass by reference and the value plus one. Is that the reason the compiler can not get the address of "++value",so it will be discarded,sorry for the fist submit.