fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float foo2(float& i)
  5. {
  6. cout << "call from reference" << endl;
  7. return i;
  8. }
  9. float foo2(float i)
  10. {
  11. cout << "call from non reference"<<endl;
  12. return i;
  13. }
  14.  
  15. typedef float (*fptr)(float&);
  16.  
  17. int main()
  18. {
  19. cout<<foo2(2) << endl; // print "call from non reference"
  20. fptr foo2ptr(foo2);
  21. float n = 10;
  22. cout<<foo2ptr(n) << endl;
  23. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
call from non reference
2
call from reference
10