Thread: Why function in functions ?? ( not recursion )

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    88

    Why function in functions ?? ( not recursion )

    Code:
    void CTransparentDialogDlg::OnLButtonDown(UINT nFlags, CPoint point) 
    {
      CDialog::OnLButtonDown(nFlags, point); //<<<< this
    }
    
    void CTransparentDialogDlg::OnSize(UINT nType, int cx, int cy) 
    {
      CDialog::OnSize(nType, cx, cy); //<< and this 
    }
    what is the usage of these funcitons ?

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    I'm not familar with the technicnology your using, is MFC, COM or something else? However, I think I have a possible explanation, but it's deep.

    Let's look at what is happening.

    CTransparentDialogDlg is derived from CDialog class right? And CTransparentDialogDlg class is overriding certain methods, but then simply calling the parent method explicitly? Why do this? Initially there doesn't seem to be a reason. But I think I have one...

    My guess is that CTransparentDialogDlg & CDialog classes are concrete classes. If there are corresponding pure virtual interface classes called ITransparentDialogDlg and IDialog, then this is the case.

    I suspect that this code is library which can be used on different compilers on Windows. Different compilers share the same v-table for objects in order to support compatiblity with COM. However, this v-table compatibility doesn't extend to inheritence. Therefore, in order to provide for inherited methods, while keeping things compatible, methods are replicated rather than inherited.

    Does this make sense?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    88
    this is MFC code.

    >>>"CTransparentDialogDlg is derived from CDialog class right? And CTransparentDialogDlg class is overriding certain methods, but then simply calling the parent method explicitly? Why do this? Initially there doesn't seem to be a reason. But I think I have one..."

    i understood a little.
    thank you for explaining.


    But i think that this is not that question NOW,

    "CDialog::OnLButtonDown(nFlags, point);"
    is that running the function of a class ?? and not the function of an Object ??
    can it run the function of a class directly??

  4. #4
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    It is running the object's ancester method.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    88
    Originally posted by Davros
    It is running the object's ancester method.
    thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. function pointers and member functions
    By thor in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2002, 04:22 PM