fork download
  1. #include <iostream>
  2.  
  3. static int const a_const = 5;
  4.  
  5. int const& A() {
  6. return a_const;
  7. }
  8.  
  9. static int const* b_ptr = 0;
  10.  
  11. int const& B() {
  12. return *b_ptr;
  13. }
  14.  
  15. int main() {
  16. int const& a_ref = A();
  17.  
  18. std::cout << "Called A()" << std::endl;
  19. std::cout << "a_ref: " << a_ref << std::endl;
  20.  
  21. int const& b_ref = B();
  22.  
  23. std::cout << "Called B()" << std::endl;
  24. std::cout << "b_ref: " << b_ref << std::endl;
  25.  
  26. return 0;
  27. }
Runtime error #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
Called A()
a_ref: 5
Called B()