Forward declaration compilation error

To add comments, please log in or register
williamwong
356
williamwong  

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) {}
};
Stanislav Korotky
25205
Stanislav Korotky  
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.

whroeder1
17927
whroeder1  
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.
williamwong
356
williamwong  
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:
To add comments, please log in or register