Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why not virtual functions to handle messages?

Answers were Sorted based on User's Feedback



Why not virtual functions to handle messages?..

Answer / chandrasekharreddy siddamreddy

In MFC we have lot of base classes those are having so many
virtual functions. For each class one virtual table will be
created. This will consume lot of memory and our application
performance will go down. This is the only reason MFC is not
using virtual function for message mapping.

Is This Answer Correct ?    13 Yes 4 No

Why not virtual functions to handle messages?..

Answer / abhijit

Implementing virtual mechanism to handle messages would
have made the message dispatch process very expensive as
* every class of any window type would have a huge virtual
function dispatch table associated with it.

Instead having static array of function pointers ensures
only one copy for a given class

Is This Answer Correct ?    5 Yes 2 No

Why not virtual functions to handle messages?..

Answer / spiker

Only classes derived from the CCmdTarget class can get the benefits of message map.For that we need to use DECLARE_MESSAGEMAP, BEGIN_MESSAGEMAP, END_MESSAGEMAP macros.
when we declare a message map it will create an array to keep all the information about the messages to be handled.

Overall the messages are handled by the base class CCmdTarget.
Virtual function is one of the best concept of oops,its for managing objects and functions.

No need of vtables to handle messages.

Is This Answer Correct ?    1 Yes 0 No

Why not virtual functions to handle messages?..

Answer / ctharam

Virtual functions are not space-efficient because they require vtables, and vtables consume memory even if the functions in them are not overridden.

The amount of memory used by a message map, in contrast, is proportional to the number of message entries it contains.

Since it's extremely rare for a developer to implement a window class that includes handlers for all of the different types of messages, message mapping conserves a few hundred bytes of memory just about every time a CWnd is wrapped around an HWnd.

Is This Answer Correct ?    1 Yes 0 No

Why not virtual functions to handle messages?..

Answer / malli

we have to prefix "afx_msg" before every function to create
message map.

Is This Answer Correct ?    0 Yes 12 No

Post New Answer

More MFC Interview Questions

What is the base class for most MFC classes?

7 Answers   CMC, Siemens,


Which Macro is a Super set of other two macro DECLARE_SERIAL,DECLARE_DYNAMIC and DECLARE_DYNCREATE. ?

2 Answers   Sony,


How can we create thread in MFC framework?

3 Answers  


if no message handler is available for a message then will deal with the message ? does window proving any default mechanism?

2 Answers   Patni,


How to handle dynamic menus in mfc? What happens when client calls cocreateinstance?

0 Answers  


WHAT IS DIFFERENT BETWEN RELEASE MODE & DEBUGGING MODE

4 Answers   Google, Microsoft, TCS,


how many types of classes are ther,what are that

7 Answers   L&T,


Whats is DDX & DDV in MFC?

1 Answers   HCL,


Hi can anyone explain about the synchronization objects types and where we are using in the code.

1 Answers  


What is LoadLibrary function returns?

7 Answers  


What is the difference between GetMessage and PeekMessage ?

3 Answers  


What is Thread ?(VC++)What is the difference between Cmutex and Csemaphone?

5 Answers   Atos Origin,


Categories