CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2012
    Posts
    3

    access member function

    In my MFC, CMyPorpertyPageDlg is derived from CPropertyPage. How to access its member function from a nonmember function in the same CPP file?.
    void Non_Member_Get_PorpertyPage()
    {
    CMyPorpertyPageDlg* pPageDlg = ....
    }

  2. #2
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: access member function

    Use a global or create a dynamic instance inside your non member function.
    ◄◄ hypheni ►►

  3. #3
    Join Date
    Dec 2012
    Posts
    3

    Re: access member function

    I did the dynamic instance: CMyPropertyPagedlg* p = new CMyPropertyPagedlg(); This did not work. can you show me in actual code the both methods, if possible?.

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: access member function

    Why is it a non-member function?
    Can't you pass a pointer to the CMyPropertyPageDlg instance to the non-member function call?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: access member function

    The typical approach there is to pass in a reference or pointer to the function. Failing that, unless you have a global instance of your object, there isn't much you can do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured