Access members of another class?

  • Thread starter Thread starter sweetjones
  • Start date Start date
  • Tags Tags
    Class Members
AI Thread Summary
The discussion revolves around a user working with Visual Studio C++ 2005 and MFC, trying to pass a CString variable (m_CustName) from one CFormView dialog to another. The user aims to set the title of the next dialog to the value of m_CustName when a button is clicked. Initially, the code compiles but results in an unhandled exception when the button is pressed, indicating an issue with pointer usage. The user later identifies that the problem stemmed from using the wrong pointer object to access the variable. This highlights the importance of correctly managing pointers and object references in MFC applications to avoid runtime errors.
sweetjones
Messages
44
Reaction score
0
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 I am 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!
 
Technology news on Phys.org
I figured out my problem. I was using the wrong *pointer object.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top