Because c ++ is usually used for writingCode, You may want to write the callback function as a method in the class, But first take a look at the following code:
Class ccallbacktester { Public: Int callback compareints (const byte * velem1, const byte * velem2 ); }; Bubblesort (byte *) array, 5, sizeof (array [0]), & Ccallbacktester: compareints );
|
If Microsoft compiler is used, the following compilation error is returned:
Error c2664: 'bubblesort ': cannot convert parameter 4 from 'Int (_ stdcall ccallbacktester: *) (const unsigned char *, Const unsigned char *) 'to' int (_ stdcall *) (const unsigned char *, Const unsigned char *) 'There is no context in which this conversion is possible
|
This is because a non-static member function has an additional parameter: This pointer, which forces you to add static before the member function. Of course, there are several ways to solve this problem, but we will not discuss it any more.
From: http://www.vczx.com/article/show.php? Id = 1007314