fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. int& m_field;
  7. A() : m_field{*new int{1}} {}
  8. ~A(){ delete &m_field; }
  9.  
  10. };
  11.  
  12. int main()
  13. {
  14. A a;
  15. a.m_field += 2;
  16.  
  17. std::cout << "a.m_field = " << a.m_field << std::endl;
  18. // your code goes here
  19. return 0;
  20. }
  21.  
  22.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
a.m_field = 3