fork download
  1. #include<iostream>
  2. using namespace std;
  3. /* such a function will not be safe if x is non static variable of it */
  4. int &fun()
  5. {
  6. static int x;
  7. return x;
  8. }
  9.  
  10. int main()
  11. {
  12. fun() = 10;
  13. /* this line prints 10 on screen */
  14. printf(" %d ", fun());
  15. getchar();
  16. return 0;
  17. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
 10