What is the base class for MFC Framework? What are the main features provided by CObject class? What is CALLBACK? How it work? What is the advantage of CALLBACK?What is the base class for MFC Framework? What are the main features provided by CObject class?
CObject class is the main base class for MFC Framework. It is the mother of all other classes. Almost all classes in MFC are derived from CObject one of the exception is CString. It provides several important features such as
Serialization - conversion of object to a series of bytes that can be written to disk and brought back later to restore your object to its previous state. 1) Runtime type information 2) Debugging features 3) Object diagnostic output 4) Compatibility with collection classes
What is CALLBACK? How it work? What is the advantage of CALLBACK? Explain with an example.
Callback is a function that is called from a function pointer. If you pass a pointer as an argument to another function and another function calls back the previous function it is called as CALLBACK. The main advantage of this is to detach caller from the callee. In this caller doesn’t care about the callee but caller knows that there is some callee exists with some prototype and with some functionality in hand. So it provides and abstraction. For example, if suppose you write a library program that provides implementation of all sorting algorithms. But you don’t want to put any sorting logic into your functions by yourself and making it more general to use. You want client to make decision of the algorithm they want to use. So, for this the function pointers will be used which will be making callbacks.
|