1. Callback style in C ++. In the C era, when an asynchronous call is made, if the other party wants to notify itself of the execution result, it generally registers a function pointer during the call. After the other party completes the execution, execute the function pointed to by the function pointer to reach the wood of the notification. In C ++, an interface is used to replace the function pointer. For example
Class Delegate
{
Public:
Virtual Void Response(STD::String& Resultstr) = 0;
};
Class Calldelegate :Public Delegate
{
Public:
Reponse ()
{
STD: Cout <resultstr <STD: Endl;
}
};
When an asynchronous call is made, the other party only knows the delegate and sends a calldelegate pointer to the other party. After the other party completes the execution, it calls the response function to complete the asynchronous notification execution result.