Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // file: X.h
  2. class X {
  3. public:
  4. X() {};
  5. ~X() {};
  6.  
  7. void fooX() { // do stuff };
  8. void barX() { // do more stuff };
  9. }
  10.  
  11. // file: X.cpp
  12. #include "X.h";
  13.  
  14. // file: Y.h
  15. #include "X.h"
  16. class Y {
  17. public:
  18. Y() {x = new X()};
  19. ~Y() {};
  20.  
  21. fooY() { // do stuff };
  22. barY() { // do more stuff };
  23.  
  24. private:
  25. X x; // object of class X
  26. }
  27.  
  28. // file: Y.cpp
  29. #include "Y.h"
  30.  
  31. // file: Z.h
  32. #include "Y.h"
  33. class Z {
  34. public:
  35. Z(uint8_t, std::string, std::vector<uint8_t>);
  36. ~Z() {};
  37.  
  38. fooZ() { // do stuff };
  39. barZ() { // do more stuff };
  40.  
  41. private:
  42. Y y; // object of class Y
  43. }
  44.  
  45. // file: Z.cpp
  46. #include "Z.h"
  47. Z::Z(uint8_t a, std::string b, std::vector<uint8_t> c)
  48. {
  49. /// do stuff and create an object of Y
  50. Y y = new Y();
  51. }
  52.  
  53. // file api.h
  54. #include "Z.h"
  55. void accessZ(uint8_t, std::string, std::vector<uint8_t>);
  56.  
  57. // file api.cpp
  58. #include "api.h"
  59. void accessZ(uint8_t a_uint,
  60. std::string b_string,
  61. std::vector<uint8_t> c_vector)
  62. {
  63. // create object of Z
  64. Z z = new Z(a_uint, b_string, c_vector);
  65. z->fooZ();
  66.  
  67. delete z;
  68. z = NULL;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement