I couldn't understand the output of this program even after a debug, specially the line where you find " f(::x) = h(x) " what does it mean ? Could someone help me please to understand the C++ program and how it runs to understand the outputs.
#include<iostream>
using namespace std;
int x = 6;
int h(int & x){x = 2*x; return x;}
int g(int m){return x++;}
int & f(int &x){x+=::x; return x;}
int main()
{
int x = -1;
f(::x) = h(x);
cout<<f(x)<<" "<<g(x)<<" "<<h(x)<<" "<<x<<" "<<::x<<endl;
f(::x) = g(x);
cout<<f(x)<<" "<<g(x)<<" "<<h(x)<<" "<<x<<" "<<::x<<endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire