Guest User

Untitled

a guest
Nov 14th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #ifndef _A_h
  2. #define _A_h
  3.  
  4. class A{
  5. public:
  6. A(int id);
  7. private:
  8. int _id;
  9. B _b; // HERE I GET A COMPILATION ERROR: B does not name a type
  10. };
  11.  
  12. #endif
  13.  
  14. #include "A.h"
  15. #include "B.h"
  16. #include <cstdio>
  17.  
  18. A::A(int id): _id(id), _b(){
  19. printf("hellon the id is: %dn", _id);
  20. }
  21.  
  22. #ifndef _B_h
  23. #define _B_h
  24.  
  25. class B{
  26. public:
  27. B();
  28. };
  29. #endif
  30.  
  31. #include "B.h"
  32. #include <cstdio>
  33.  
  34. B::B(){
  35. printf("this is hello from Bn");
  36. }
  37.  
  38. class B; // forward declaration
  39. class A {
  40. public:
  41. A(int id);
  42. private:
  43. int _id;
  44. B & _b;
  45. };
  46.  
  47. error 'Class' does not name a type
Add Comment
Please, Sign In to add comment