Archived

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

DanG

classes including each other, anyway around?

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 this post


Link to post
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

Share this post


Link to post
Share on other sites