fork download
  1. #include <iostream>
  2.  
  3. const int& MyConstValue(int x) {
  4. static const int myConstValue = x;
  5. return myConstValue;
  6. }
  7.  
  8. int main() {
  9. std::cout << MyConstValue(5) << std::endl; // This is the 1st call and "wins"
  10. std::cout << MyConstValue(8) << std::endl;
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
5
5