Advertisement

C++ Classes pointing to eachother? Seems it should work somehow...

Started by November 22, 2000 04:12 PM
11 comments, last by BeanDog 24 years, 2 months ago
Hello,
I had this same problem some time ago. I have since fixed it. The only thing that is giving me problems is that things work fine as a stand alone program but if I try to export the class from a DLL I cant do it because of the embedded classes created when using the smart pointers I have to various objects. I use the smart pointer code presented in an article here on gamedev:
http://www.gamedev.net/reference/programming/features/llgc/

I have the classes laid out similar to the following:

In myClass1.h:

#include "refcnt.h"
#include "myClass2.h"
class EXDLL myClass2 : public RefCntObject
{
...
RefCntPointer< myClass2 > m_myClass2Ptr;
}


In myClass2.h:

#include "refcnt.h"
class EXDLL myClass1;
class EXDLL myClass2 : public RefCntObject
{
...
RefCntPointer< myClass1 > m_myClass1Ptr;
}

Now this layout works fine in a stand alone prog as I stated but seeing as how I''m just learning all the quirks will dlls I''m stumped on a good way to go about alleviating the problem with the Pointer classes when exportin the classes from a dll. I could just change all the pointer classes to plain ol'' pointers and be done with it, but I really wanted to use the pointer classes. I''ve been readin around some and read that I can do:

template class EXDLL RefCntPointer< myClass1 >;
template class EXDLL RefCntPointer< myClass2 >;

And doing this I can get partially there but since one class isnt defined in one header because of the cross reference I cant do it for the other correctly. Or can I?

Does anyone know of a good way of doing this? Am I overlooking something completely obvious that I should have learned in C++ 101? Any help, ideas, advice, etc. would be greatly appreciated.

Hopefull I explained this right.

Thanks in advance.

I look up to you dire.wolf ;-)
-Ankh
Advertisement
I look up to you dire.wolf ;-)
-Ankh

This topic is closed to new replies.

Advertisement