| | |
Grabbing a reference to or pointer to...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 22
Reputation:
Solved Threads: 0
Hi guys,
I was hoping someone could explain to me how I would go about grabbing a pointer/reference to my variable 'textName' contained within the Reports class, (some code omitted to try to simplify the scenario)
I was hoping someone could explain to me how I would go about grabbing a pointer/reference to my variable 'textName' contained within the Reports class, (some code omitted to try to simplify the scenario)
C++ Syntax (Toggle Plain Text)
//Reports.h class Reports : public wxPanel { public: void AddStudent(wxCommandEvent & event); wxTextCtrl *textName; // declare variable };
C++ Syntax (Toggle Plain Text)
//Reports.cpp Reports::Reports(wxPanel * parent) : wxPanel(parent, wxID_ANY, wxPoint(-1, -1), wxSize(500, 500)) { wxTextCtrl *textName = new wxTextCtrl(this, wxID_AddStudent, wxT(""), wxPoint(65, 65)); } void Reports::AddStudent(wxCommandEvent & WXUNUSED(event)) { // The following breaks the code, I want to grab textName textName.SetValue("Test"); textName.SetFocus(); /* ************************* If I re-create textName then access (as shown in the following commented code) then it works fine but I can't work out how to create a pointer/reference to the previous textName rather than having to re-create one! wxTextCtrl *textName = new wxTextCtrl(this,wxID_AddStudent, wxT("Another button..."), wxPoint(65, 95)); textName->SetValue("Testing"); textName->SetFocus(); *******************************/ }
![]() |
Similar Threads
- Pointer troubles (C++)
- pointer to a refernce (C++)
- returning by reference (C)
- pointer (C)
Other Threads in the C++ Forum
- Previous Thread: Why this code doesnt work?
- Next Thread: std::string capacity(). Different in different OSs?!?!
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





