fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double & foo()
  5. {
  6. double n = 12.4;
  7. double &ref = n;
  8. return ref;
  9. }
  10.  
  11. double * foo2()
  12. {
  13. double n = 12.4;
  14. double *ref = &n;
  15. return ref;
  16. }
  17.  
  18. double foo3()
  19. {
  20. double n = 12.4;
  21. return n;
  22. }
  23.  
  24. int main()
  25. {
  26. double x = foo();
  27. cout << x << endl;
  28.  
  29. double *y = foo2();
  30. x = *y;
  31. cout << x << endl;
  32.  
  33. x = foo3();
  34. cout << x << endl;
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0
0
12.4