fork(1) download
  1. #include <iostream>
  2.  
  3. // === library code ===
  4. struct A {
  5. int x, y;
  6. A(int x, int y) : x(x), y(y) {}
  7. };
  8. A getSomeA(int x, int y) {
  9. return A(x, y);
  10. }
  11. // === end of library code ===
  12.  
  13. class B : public A {
  14. public:
  15. B (A &&a) : A(a), someOtherMember(a.x + a.y) {}
  16.  
  17. // added public stuff:
  18. int someOtherFunction() const { return someOtherMember; }
  19.  
  20. private:
  21. // added private stuff:
  22. int someOtherMember;
  23. };
  24.  
  25. int main() {
  26. B b(getSomeA(32, 10));
  27. std::cout << b.x << ", " << b.y << std::endl;
  28. std::cout << b.someOtherFunction() << std::endl;
  29. };
  30.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
32, 10
42