| | |
Grabbing a reference to or pointer to...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 54
Reputation:
Solved Threads: 3
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?!?!
Views: 198 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





