So I made some changes as below and though it all works like charm now, I don't know what's really happening between two functions and generally what you did to make it work? would appreciate your explanation here. |
Non-static member functions have an extra parameter called the
implicit object parameter. The implicit object parameter is a reference to the class of which the function is a member. For example, if class
A is defined as
struct A { void f() {}; };
Then the non-static member function
A::f has an implicit object parameter of type
A&. It's not in the declaration, but it's there anyway.
So, to call
A::f you must provide an
implicit object argument corresponding to the implicit object parameter. This is the part that goes to the left of the dot, for example
my_a is the implicit object argument in
my_a.f(). You access the implicit object through the
this pointer.
Absent polymorphism, the non-static member function
A::f is conceptually the same as a non-member function
g defined as
void g(A& a) {};
So non-static member functions always have an extra parameter, and
sqlite3 can't handle this.
Non-member functions and static member functions do not have an implicit object parameter, so they avoid the problem entirely.
If you don't need to access any class members within
callback then it is useless and should be removed. To do so, replace callback with callback_thunk, make it a static member and remove the line starting with
reinterpret_cast.