I'm looking few exercise from university about C++ and I found out this exercise:
#include <iostream>
using namespace std;
int x = -2;
int h(int &x) {
x = 2 * x;
return x;
}
int g(int f) {
return x;
}
int &f(int &x) {
x += ::x;
return x;
}
int main() {
int x = 6;
f(::x) = h(x);
cout << f(x) << endl;
cout << g(x) << endl;
cout << h(x) << endl;
return 0;
}
The output of this code is :
24
12
48
Can anyone explain me how do I get this output?
And how does f(::x) = h(x);
work?