#include <iostream>
using namespace std;
float foo2(float& i)
{
cout << "call from reference" << endl;
return i;
}
float foo2(float i)
{
cout << "call from non reference"<<endl;
return i;
}
typedef float (*fptr)(float&);
int main()
{
cout<<foo2(2) << endl; // print "call from non reference"
fptr foo2ptr(foo2);
float n = 10;
cout<<foo2ptr(n) << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZmxvYXQgZm9vMihmbG9hdCYgaSkKewogICAgY291dCA8PCAiY2FsbCBmcm9tIHJlZmVyZW5jZSIgPDwgZW5kbDsKICAgIHJldHVybiBpOwp9CmZsb2F0IGZvbzIoZmxvYXQgaSkKewogICAgY291dCA8PCAiY2FsbCBmcm9tIG5vbiByZWZlcmVuY2UiPDxlbmRsOwogICAgcmV0dXJuIGk7Cn0KCnR5cGVkZWYgZmxvYXQgKCpmcHRyKShmbG9hdCYpOwoKaW50IG1haW4oKQp7CiAgICBjb3V0PDxmb28yKDIpIDw8IGVuZGw7IC8vIHByaW50ICJjYWxsIGZyb20gbm9uIHJlZmVyZW5jZSIKICAgIGZwdHIgZm9vMnB0cihmb28yKTsKICAgIGZsb2F0IG4gPSAxMDsKICAgIGNvdXQ8PGZvbzJwdHIobikgPDwgZW5kbDsKfQ==