fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class test
  6. {
  7. private: int a;
  8. public: test(){a=6;}
  9. int& print(){return a;}
  10. };
  11.  
  12. int main()
  13. {
  14. test one;
  15. int& b = one.print();
  16. b = 8;
  17. cout << one.print() << endl;
  18. }
  19.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
8