fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int &f(int n = -1)
  5. {
  6. static int c;
  7. if (n >= 0) {
  8. c = n * 10;
  9. }
  10. return c;
  11. }
  12.  
  13. int main()
  14. {
  15. cout << f(1) << endl;
  16. cout << f() << endl;
  17. f() = 2;
  18. cout << f() << endl;
  19. f(3);
  20. cout << f() << endl;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
10
10
2
30