What you are passing here is a pointer to a function. The name of a function is always it's address, like using the address-of operator automatically. This address, of course, refers to the starting point of the function in memory. However, in this case, the constructor seems to create a copy of the function, and move it into a seperate place in memory. I do not know why it does this, but calling the function does work properly. Here is the code fragment with which I tested it.
#include <iostream>
using namespace std;
typedef void (*ptrFunc1)(int, int, double, double);
void MyFunction( int a, int b, double c, double d )
{
cout << "Inserted: " << a << " " << b << " " << c << " " << d << "\n\n";
}
class Nothing
{
public:
Nothing(ptrFunc1 func1);
};
Nothing::Nothing(ptrFunc1 func1)
{
int a = 10;
int b = 20;
double c = 30;
double d = 40;
func1(a, b, c, d);
}
int main(void)
{
Nothing MyNothing(MyFunction);
}
Although whilst in debugging, the addresses of MyFunction and func1 are different, and even (*func1) points to a different place than MyFunction, the code calls MyFunction properly through the func1 function pointer, and the text gets printed out correctly. I see no reason why your implementation would not work properly as well. The reasons of why the memory locations are different is unknown to me, it would require some more work to determine it. I even tested it by creating two objects of class Nothing. In that case, the func1 pointed to the same location in both cases. So, although I don't understand why it happens, the code works, so you shouldn't have anything to worry on that part :) -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.