C ++ application and implementation of the callback function

1, using a callback function, you should distinguish who is the user, who is a library provider. Implemented by the user side callback function and the callback function registered to the library provider in some form, and then call the library provider callback function when a specific event or condition occurs.

2, the simplest form of a callback function through a function pointer is passed directly to the Provider library, then the library provided by the party uses to implement callback function pointer.

3, in addition, to build a database provider base class and the corresponding interface, the user side and then create and implement its subclasses base interface. A subclass object can be constructed, and the subclass object provider registered to the library (typically in the form of void or base pointer variable as a member of the library). Finally, the polymorphic function can be realized on the user side of the call.

4、

Guess you like

Origin www.cnblogs.com/share-ideas/p/11222130.html