Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _A_h
- #define _A_h
- class A{
- public:
- A(int id);
- private:
- int _id;
- B _b; // HERE I GET A COMPILATION ERROR: B does not name a type
- };
- #endif
- #include "A.h"
- #include "B.h"
- #include <cstdio>
- A::A(int id): _id(id), _b(){
- printf("hellon the id is: %dn", _id);
- }
- #ifndef _B_h
- #define _B_h
- class B{
- public:
- B();
- };
- #endif
- #include "B.h"
- #include <cstdio>
- B::B(){
- printf("this is hello from Bn");
- }
- class B; // forward declaration
- class A {
- public:
- A(int id);
- private:
- int _id;
- B & _b;
- };
- error 'Class' does not name a type
Add Comment
Please, Sign In to add comment