There are two methods to handle third-party includes:
a) put the #include of the third party header inside your own header
b) don't embed a full object of the third party, but just a pointer. In your case that would look like:
class __declspec( dllexport ) Myclass
Then allocate the object inside your Myclass constructor. That way, you only need to make an advance declaration of the third-party class (first line in the code above).
There are two more techniques worth mentioning.
- on the Microsoft platform you can use #pragma directives inside your library code to save the users of your library the work of putting your library on the linker input list. For example
#pragma comment (lib, "MyLib.lib")
- use the so-called PIMPL technique (stands for pointer to pointer-to-implementation). This means: Declare just a single data member inside your class, which is a pointer to an implementation class. Then, in the .cpp file your declare an implementation class with all the member data you need. For example:
m_pThis = new MyClassImpl;
This is a nice technique to insolate your class and let the exterior only know the bare minimum about your class. Particularly: The external size of the class always stays the same (just the size of the pointer). That is very useful when your class is part of a library and the user allocates objects of your class in his own code. You may then add members to your implementation without having the user to recompile his entire code.