The standard implementation of the pImpl idiom puts the following code in the .h file:
class MyClassImpl;
class MyClass
{
public:
MyClass();
~MyClass();
MyClass(const MyClass&);
MyClass& operator=(const MyClass&);
private:
MyClassImpl* pImpl;
};
But, this requires the constructors and destructors to be provided to the user of my library in a form of a .LIB file (static library). However, I want to create a DLL library that does not require the user to link with additional static libraries. There are some funcions like this:
__declspec(dllexport)
void MyFunction(MyClass& object);
And the user needs to create the object before passing it to the function. Thus, he needs access to the constructor and destructor.
What is the most correct way to design the API of such library?