fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A{
  5. public:
  6. int a;
  7. A (int a_ = 0) : a(a_) {}
  8. };
  9.  
  10. int * c;
  11.  
  12. A& generator(int b = 5) {
  13. A& a = *new A(b);
  14. c = &(a.a);
  15. return a;
  16. }
  17.  
  18. int main() {
  19. // your code goes here
  20. A& a = generator();
  21. std::cout << a.a << std::endl;
  22. *c = 6;
  23. std::cout << a.a << std::endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
5
6