Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <list>
- class A;
- class B
- {
- B();
- public:
- A* a; //only this use is allowed with only a forward declaration, without the actual declaration
- //A a2; // this would require the declaration of A
- };
- //actual declaration of class A:
- class A
- {
- public:
- A();
- int i;
- typedef std::list<int> AiLst;
- };
- int main()
- {
- // using something else than declaring a pointer to A is allowed now.
- A::AiLst lst;
- A a;
- return 0;
- }
- // this is the definition and can come later in the same translation unit.
- A::A():i(0){}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement