fork download
  1. #include <iostream>
  2.  
  3. int global = 1;
  4.  
  5. int& getGlobal() {
  6. std::cout << "getGlobal() called\n";
  7. return global;
  8. }
  9.  
  10. int getSomeInt() {
  11. std::cout << "getSomeInt() called\n";
  12. return 2;
  13. }
  14.  
  15. int main() {
  16. getGlobal() = getSomeInt();
  17. }
  18.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
getGlobal() called
getSomeInt() called