1. Callback Function (from Baidu encyclopedia)
Why should I use a callback function?
Callback can be used in the notification mechanism. For example, if you want to set a timer in program a, program A will be notified at a certain time, but the implementer of the notification mechanism knows nothing about program. Then, a function pointer with a specific prototype is required for callback to notify program a that the event has occurred. In fact, the settimer () API uses a callback function to notify the timer. If the callback function is not provided, a message is sent to the Message Queue of the program.
Another API function that uses the callback mechanism is enumwindow (), which enumerates all the top-level windows on the screen. Each window can call the functions provided by another program through it, and transfer the processing program of the window. For example, if the caller returns a value, iteration continues. Otherwise, exit. Enumwindow () does not care about where the caller is or what the handler passed by the caller is. It only cares about the returned value because it will continue to execute or exit based on the returned value.
In any case, the callback function continues from the C language. In C ++, the callback function should be used only when an interface is established with C code or when dealing with an existing callback interface. In addition to the above cases, the virtual method or function operator should be used in C ++, rather than the callback function.
2,
// Blmgxfixmaincontroller. h
Class bshmmessagerecord;
Class bshmorderdetailrecord;
Class blmgxfixmaincontroller: Public blmterminalmaincontroler {}
What is the difference between declaring other classes in blmgxfixmaincontroller. h and header files containing other classes?
Why do I call other classes in declarative mode?
The header file only needs to declare a class. If the function declaration only needs to use a class pointer or reference it, You can declare this class. The header file can contain it in the CC file.
I also see the online explanation, for example, bshmmessagerecord. h already contains blmgxfixmaincontroller. H, so the class bshmmessagerecord method is used in blmgxfixmaincontroller. h? Is that true?
If you only declare it, the problem of mutual inclusion can be solved.