in function cuber() x is passed by reference. That means if you change it value, value of passed function will be changed too.
I must note, that you do not return value from function declared as returning one. It leads to undefined behavior. That means anything can happen. It is absolutely legal for compiler go generate code formatting your hard drive and it will be conforming to standard.
#include <iostream>
usingnamespace std;
int cubev(int x);
void cuber(int & x);
int main()
{
int x = 3;
// pass by reference
cuber(x);
cout << x << endl; // show x, now its 27.
// reset x
x = 3;
cout << cubev(x) << endl;
return 0;
}
int cubev(int x)
{
x = x*x*x;
return x;
}
void cuber(int &x)
{
x = x*x*x;
}