fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. namespace A
  5. {
  6. class Parent
  7. {
  8. public:
  9. Parent (int a, int b, int c, int d);
  10.  
  11. protected:
  12. std::vector<double> rmats_;
  13. };
  14. }
  15. A::Parent::Parent (int a, int b, int c, int d) {
  16. rmats_.reserve(3000);
  17. rmats_.clear ();
  18. double v = 1.0;
  19. rmats_.push_back(v);
  20. std::cout << "size of rmats is " << rmats_.size() << std::endl;
  21. }
  22.  
  23. namespace B
  24. {
  25. class Child : public A::Parent
  26. {
  27. public:
  28. Child(int a, int b, int c, int d);
  29. };
  30. }
  31. B::Child::Child(int a, int b, int c, int d) : A::Parent(a,b,c,d)
  32. {
  33. std::cout << "size of rmats in the child is " << rmats_.size() << std::endl;
  34. }
  35.  
  36. int main ()
  37. {
  38. B::Child mychild(1,2,3,4);
  39. return 0;
  40. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
size of rmats is 1
size of rmats in the child is 1