I use a 3rd party library, that does callback operations. It has a function which takes in function pointers. The problem is that I are unable to pass in pointers to functions that are members of a class.
I am using Qt and C++. The 3rd party library function seems to be a C function. The example code provided by the third party puts all code in main. This is undesirable, I need to wrap code in classes.
How can I solve this callback issue?
A.h
#include "ThirdPartyLibrary.h"
class A
{
public:
    QFile* f;
    A(QString filename);
    ~A();
    bool mount();
    BOOL _stdcall OnWriteCallback
    (
        DRIVE_HANDLE h, 
        ULONGLONG WriteOffset, 
        ULONG WriteSize, 
        const void* WriteBuffer, 
        ULONG *BytesWritten
    );
    BOOL _stdcall OnReadCallback
    (
        DRIVE_HANDLE h, 
        ULONGLONG ReadOffset, 
        ULONG ReadSize, 
        void* ReadBuffer, 
        ULONG *BytesRead
    );
};
A.cpp
A::A(QString filename)
{
    f = new QFile(filename);
    f.open(QFile::ReadWrite);
}
~A::A(){
    f.close();
    delete f;
}
bool A::mount()
{
    //THIS IS THE PROBLEM, CreateVirtualDrive does not take MEMBER FUNCTION POINTERS 
    //properly, instead it wants normal function pointers.
    //CreateVirtualDrive is from an external 3rd-party 
    //library, and seems to be a C function.
    g_hDrive = CreateVirtualDrive(driveLetter,DISK_SIZE,
                                  &A::OnReadCallback,
                                  &A::OnWriteCallback);
}
BOOL _stdcall A::OnWriteCallback
(
    DRIVE_HANDLE h, 
    ULONGLONG WriteOffset, 
    ULONG WriteSize, 
    const void* WriteBuffer, 
    ULONG *BytesWritten
){
    //do some work with QFile f !!
    return true;
}
BOOL _stdcall A::OnReadCallback
(
    DRIVE_HANDLE h, 
    ULONGLONG ReadOffset, 
    ULONG ReadSize, 
    void* ReadBuffer, 
    ULONG *BytesRead
){
    //do some work with QFile f !!
    return true;
}
main.cpp
#include "A.h"
int main ()
{
    A a;
    a.mount();
}