Member variable in different CPP file - Programmer

This is a discussion on Member variable in different CPP file - Programmer ; Hi, I have a member variable CTreeCtrl declared in View file (automatically by ClassWizard). I have to use this variable in other file (MainFrm.cpp). I've tried use extern and include but several errors appears. :/ Please help. TIA! Deli...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Member variable in different CPP file

  1. Member variable in different CPP file

    Hi,

    I have a member variable CTreeCtrl declared in View file (automatically by
    ClassWizard).
    I have to use this variable in other file (MainFrm.cpp). I've tried use
    extern
    and include but several errors appears. :/
    Please help. TIA!

    Deli


  2. Re: Member variable in different CPP file

    Deli wrote:
    > Hi,
    >
    > I have a member variable CTreeCtrl declared in View file (automatically by
    > ClassWizard).
    > I have to use this variable in other file (MainFrm.cpp). I've tried use
    > extern
    > and include but several errors appears. :/
    > Please help. TIA!
    >
    > Deli
    >


    If it is a member variable of CMainFrame then you should add a function
    in CMainFrame to get/put the data you want, like GetSomeData. Then call
    the CMainFrame object from elsewhere.

    CMainFrame* pmain = (CMainFrame*)AfxGetMainWnd();
    pmain->GetSomeData();

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread