From: http://doc.qt.nokia.com/4.7/signalsandslots.html
Callbacks have two fundamental flaws: Firstly, they are not type-safe. We can never be certain
Please look at sqlite3_exec() as a good example. It's void*
parameter is a pointer to a "context object" that is passed into the callback function when the latter is called. It's totally up to the user to be sure that this void*
points to a type he expects.
For example, you need some complex class as a "context object". You pass an address of an object of that class into sqlite3_exec()
and it's implicitly converted into void*
, then when your callback is called you have to cast it back from void*
and noone catches you if you cast it to the wrong type.