#### Archived

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

# classes including each other, anyway around?

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

## Recommended Posts

I currently have two classes in my Tetris clone. One is Field, representing the play space, and the other is block, representing a single square area. Problem is each has a reference to the other and the compiler doesn''t like it. Here is what it looks like: // Field.h class Field { vector > m_Field; }; // Block.h class Block { Field & m_rField; } Problem is that to define one requires the other, so I can''t seem to get the compiler to relize the two exist. Any ideas?

##### Share on other sites
Read up on forward declaring and friends.

##### Share on other sites
one way would be:

  class A;class B{  private:    A* a;};class A{};

This would be called forward declaring , mentioned by AP.

Crispy