#include <iostream>
using namespace std;
double & foo()
{
double n = 12.4;
double &ref = n;
return ref;
}
double * foo2()
{
double n = 12.4;
double *ref = &n;
return ref;
}
double foo3()
{
double n = 12.4;
return n;
}
int main()
{
double x = foo();
cout << x << endl;
double *y = foo2();
x = *y;
cout << x << endl;
x = foo3();
cout << x << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZG91YmxlICYgZm9vKCkKewogICAgZG91YmxlIG4gPSAxMi40OwogICAgZG91YmxlICZyZWYgPSBuOwogICAgcmV0dXJuIHJlZjsKfQoKZG91YmxlICogZm9vMigpCnsKCWRvdWJsZSBuID0gMTIuNDsKICAgIGRvdWJsZSAqcmVmID0gJm47CiAgICByZXR1cm4gcmVmOwp9Cgpkb3VibGUgZm9vMygpCnsKCWRvdWJsZSBuID0gMTIuNDsKCXJldHVybiBuOwp9CgppbnQgbWFpbigpCnsKCSAgZG91YmxlIHggPSBmb28oKTsKCSAgY291dCA8PCB4IDw8IGVuZGw7CgkgIAoJICBkb3VibGUgKnkgPSBmb28yKCk7CgkgIHggPSAqeTsKCSAgY291dCA8PCB4IDw8IGVuZGw7CgkgIAoJICB4ID0gZm9vMygpOwoJICBjb3V0IDw8IHggPDwgZW5kbDsKCSAgCgkgIHJldHVybiAwOwp9