Hello all,
I want to have multiple instances of a DLLInterface class but as each object will have pointers to the same DLL functions I want these to be static.
The below code doesn't compile. (I do have a reason for needing multiple instances containing the same pointers which the stripped down code below doesn't illustrate.)
//Header file:
typedef void (*DLLFunction)();
class DLLInterface
{
private:
static HINSTANCE hinstDLL;
public:
static DLLFunction Do;
DLLInterface()
{
if(!hinstDLL || !Do)
{
hinstDLL = LoadLibrary("DoubleThink.dll");
Do = (DLLFunction)GetProcAddress(hinstDLL, "Do");
}
}
};
I need to have all code contained within this header file also. (I know I can make it compile by adding statements like the following into a cpp file on the EXE but I need to avoid doing this.
HINSTANCE DLLInterface::hinstDLL = 0;
Thanks!