Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Access members of another class?

  1. Mar 26, 2008 #1
    I'm using VS C++ 2005 in MFC, and I'm trying to access a member of another class. I'll try and make this as short as possible and still give the whole picture of what im trying to do. I created a SDI with the CFormView Class. I have a dialog with an edit control box with a CString variable(m_CustName) and a CEdit control(m_CtrlCustName). I've done this to store the name(m_ctrlCustName.GetWindowTextW(m_sCustName);). I have a button to go to the next dialog which is another CFormView Class. What I'm trying to do is take that m_CustName variable, for example, "John Doe," and make that the title of the next dialog when I click that button. This is just a piece of what I have in the next View Class, but it is not working:
    CString strTitle = CustName->m_sCustName; // CustName is a pointer object of the first class
    pDoc->SetTitle(strTitle); // pDoc is declared as a pointer object to my document class already

    My program compiles, but when I press the button to go to the next dialog a Unhandled Exception pops up, and the "atlsimplestr.h" shows. Well, any help is appreciated. Let me know if you need more clarification or info. Thanx in Advance!!!
  2. jcsd
  3. Mar 27, 2008 #2
    I figured out my problem. I was using the wrong *pointer object.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook