fork(1) download
  1. class LongLived {};
  2.  
  3. class Foo
  4. {
  5. public:
  6. Foo(LongLived& mutableLongLived)
  7. : mMutableLongLived(mutableLongLived)
  8. {}
  9.  
  10. LongLived& GetC1() { return GetC1Private(); }
  11. const LongLived& GetC1() const { return GetC1Private(); }
  12.  
  13. private:
  14. LongLived& GetC1Private() const {
  15. // pretend a bunch of lines of code instead of just returning a single variable
  16. return mMutableLongLived;
  17. }
  18.  
  19. LongLived& mMutableLongLived;
  20. };
  21.  
  22. int main() {
  23. LongLived longLiver;
  24. const Foo foo(longLiver);
  25. foo.GetC1();
  26. return 0;
  27. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
Standard output is empty