fork download
  1. #include <iomanip>
  2. #include <iostream>
  3.  
  4.  
  5. class foo {
  6.  
  7. public:
  8.  
  9. int & i;
  10.  
  11. };
  12.  
  13.  
  14. int main (void) {
  15.  
  16. std::cout << std::boolalpha << (sizeof(foo)==sizeof(int *)) << std::endl;
  17.  
  18. int i=4;
  19.  
  20. foo f{i};
  21.  
  22. std::cout << f.i << std::endl;
  23.  
  24. f.i=5;
  25.  
  26. std::cout << f.i << std::endl;
  27.  
  28. std::cout << i << std::endl;
  29.  
  30. std::cout << (sizeof(int *)==sizeof(f)) << std::endl;
  31.  
  32. }
  33.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
true
4
5
5
true