#### Archived

This topic is now archived and is closed to further replies.

# classes in classes

This topic is 5698 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Another little class question.... ...I want to try and use classes as much as possible for the game I''m working on, so basically anything that can be a class will be. However, I''m finding one problem: say I have: class TypeA { int whatever; float something; TypeB *ObjectB; } TypeB is a clas define in another header file. I know I can just include that header file and all is well, but if I use that method, by the time I get half-way through making the classes, I''ll have pages of include statements in each header file, and that''s just not good. So what''s the best way of making class objects inside other classes?

##### Share on other sites
Forward declaration.

##### Share on other sites
You can also use:
class TypeB *ObjectB;

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/

##### Share on other sites
...which is an inline forward declaration.

##### Share on other sites
I had a feeling it was some kind of forward declaration, but I wasn''t sure.

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/