Forward declaration compilation error

 

The following gives CBuffer struct undefined compilation error, please help:


class C1dArray;
class C1dBuffer;
class CBuffer;
class C1dIntArray;
class C1dArray
{
   C1dBuffer   *m_1dBuffer;
};

class C1dIntArray:public C1dArray
{
};

class C1dBuffer
{
   CBuffer     m_buffer;
   C1dIntArray m_index;
};
class CBuffer
{
public:
   void a_func(C1dIntArray &array) {}
};
 
williamwong:

The following gives CBuffer struct undefined compilation error, please help:

C++ does not compile this as well. You should change m_buffer from instance to pointer type.

 
You can''t store a CBuffer in a C1dBuffer unless CBuffer is defined (not just declared.) Either move the definition higher, or store a pointer to an instance.
 
Thanks for the tip, when I change to CBuffer to pointer, it compiled ok.  Now I need to split into 4 files, I am getting the compilation error, please help.
Files:
main.mqh  2 kb
C1dArray.mqh  1 kb
C1dBuffer.mqh  2 kb
CBuffer.mqh  2 kb
Reason: