fork download
  1. #include <iostream>
  2.  
  3. struct abc{
  4. int n;
  5. };
  6. struct A{
  7. abc v;
  8. abc* FuncP(){return &v;}
  9. abc& FuncR(){return v;}
  10. };
  11.  
  12. int main(){
  13. A a;
  14. abc* p1 = a.FuncP();
  15. abc& r1 = *a.FuncP();
  16.  
  17. abc& r2 = a.FuncR();
  18. abc* p2 = &a.FuncR();
  19.  
  20. p1->n = 10;
  21. std::cout << p1->n <<","<< r1.n <<","<< p2->n <<","<< r2.n << std::endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
10,10,10,10