Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <vector>
  2.  
  3. struct MyClassImpl
  4. {
  5.     std::vector<int> vec;
  6. }
  7.  
  8. ref class MyClass
  9. {
  10.     MyClassImpl* impl;
  11.  
  12. public:
  13.     MyClass(const int n):
  14.     impl(new MyClassImpl)
  15.     {
  16.     impl->vec.resize(n, 0);
  17.     }
  18.  
  19.     ~MyClass()
  20.     {
  21.     delete impl;
  22.     }
  23. };
  24.  
  25. // Alternativamente
  26. struct MyOtherClassImpl
  27. {
  28.     std::vector<int> vec;
  29.  
  30.     MyOtherClassImpl(const int n):
  31.     vec(n)
  32.     {}
  33. }
  34.  
  35. ref class MyOtherClass
  36. {
  37.     MyOtherClassImpl* impl;
  38.  
  39. public:
  40.     MyOtherClass(const int n):
  41.     impl(new MyOtherClassImpl(n))
  42.     {
  43.     }
  44.  
  45.     ~MyOtherClass()
  46.     {
  47.     delete impl;
  48.     }
  49. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement