c++ - interdependent classes in same namespace problem -


i'm in real fix... need port code, has lot of interdependent classes , uses namespaces in order avoid includes. works in msvc, can't find way deal situation in gcc :(

contents of mystring.h file:

#include "basebuffer.h" //i can't forward declare base class, have include header  namespace test {     class my_allocator     {         static const unsigned int limit = 4096;         class mybuffer : public basebuffer<limit>         { //...         }     };      template <class t, typename alloc = my_allocator> class mycontainer     { //...     }      typedef mycontainer<char> mystring; } 


contents of basebuffer.h file:

#include "myobject.h" //#include "mystring.h" //i can't include **mystring.h**, because includes header file , can't seem find way use forward declaration of **mystring** class...  namespace test {     template <uint limit> class basebuffer : public myobject     {         public:             mystring sdata; //...     } } 


please help!

you missing guards in header files.

msvc allows through extension. therefore, there 2 ways how solve :
1. 1st solution merge 2 headers.
2. 2nd solution forward declare template class mycontainer, , create dynamically in basebuffer.hpp (instead of mystring sdata, create mystring *sdata)

edit add cpp file basebuffer, , include instead of header file. in header forward declare template class mystring, , in source can include whatever like.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -