please, if somebody can explain. I have some questions about habit of pow(a, b) function in c++ (IDE Visual Studio 2019). During exercises I found strange habit of x++ and ++x in library function pow(a,b), precisely, I can't understand why such results:
int x=1;
cout << "pow(x++, x) = " << pow(x++, x) << endl;
all right in this case, result is:
pow(x++, x)=1
but in case of:
int x=1;
cout << "pow(x, x++) = " << pow(x, x++) << endl;
result is:
pow(x, x++)=2
why postcrement effects so differently?
additional cases:
int x=1;
cout << "pow(++x, ++x) = " << pow(++x, ++x) << endl;
result is:
pow(++x, ++x)=27
it's clear, but if:
int x=1;
cout << "pow(++x, x++) = " << pow(++x, x++) << endl;
result is:
pow(++x, x++)=3
another case:
int x=1;
cout << "pow(x++, ++x) = " << pow(x++, ++x) << endl;
result is:
pow(x++, ++x)=8
and one more:
int x=1;
cout << "pow(x++, x++) = " << pow(x++, x++) << endl;
result is:
pow(x++, x++)=2
in some variations results are as expected, but in some variations - not expected.