fork download
  1. #include <vector>
  2.  
  3. class c_A {
  4. public:
  5. std::vector<int> v;
  6. c_A one_element(void) {
  7. c_A res;
  8. res.v = v;
  9. res.v.resize(1);
  10. return res;
  11. };
  12. };
  13.  
  14. class c_Aext : public c_A {
  15. public:
  16. c_Aext() : c_A() { } // just call parent's default
  17. c_Aext(const c_A c) : c_A(c) { } // call parent's copy
  18.  
  19. c_Aext one_element() {
  20. return c_Aext(c_A::one_element());
  21. }
  22. };
  23.  
  24. int main () {
  25.  
  26. c_Aext Aext;
  27. Aext.v = {0, 1, 2};
  28. c_Aext B = Aext.one_element(); // The problem
  29. return 0;
  30. };
Success #stdin #stdout 0s 4720KB
stdin
Standard input is empty
stdout
Standard output is empty