Consider this event handler's code:
Code: Select all
void MyFrame::OnOneHundredLevelDisplayGpButtonClicked(wxCommandEvent& event) {
using namespace std;
wxString course_check = wxT("MEE211");
wxString course_check_2 = wxT("MEE212");
std::map<wxString, int> first_courses;
first_courses["MEE211"] = 3;
first_courses["MEE212"] = 2;
if (first_courses.find(course_one->GetValue())) {
wxMessageBox(course_one->GetValue());
}
event.Skip();
When data is entered into wxTextCtrl course_one; and the value is either MEE211 or MEE212 and the Calculate Gp button is clicked, a wxMessageBox is presented displaying the text that was entered. Basically there is a search done within the map to check if the text entered into course_one exists in the map.
Eventually, I would like to ascertain the value of the entered text (in the case of MEE211 it's "3") and use 3 in a mathematical formula to get to a result.
As the code is compiled, I get a compilation error saying:
Code: Select all
hello_world.cpp: In member function ‘void MyFrame::OnOneHundredLevelDisplayGpButtonClicked(wxCommandEvent&)’:
hello_world.cpp:1287:27: error: could not convert ‘first_courses.std::map<wxString, int>::find(wxTextCtrl::GetValue())’ from ‘std::map<wxString, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const wxString, int> >}’ to ‘bool’
if (first_courses.find(course_one->GetValue())) {