Code: Select all
'&`: illegal operation on bound member function expression`
Code: Select all
//MainWindow.h
#pragma once
#include <wx/wxprec.h>
class MainWindow : public wxFrame
{
public:
//Constructor and Deconstructor
MainWindow(const wxString& title);
~MainWindow();
//wxWidgets
wxButton* buttonAdd;
wxButton* buttonSub;
wxStaticText* label;
//Events
void ButtonAddClicked(wxCommandEvent & event);
void ButtonSubClicked(wxCommandEvent & event);
private:
int count;
};
Code: Select all
//MainWindow.cpp
#include "MainWindow.h"
#include <wx/artprov.h>
MainWindow::MainWindow(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
wxMenuBar* menuBar = new wxMenuBar();
wxMenu* menu1 = new wxMenu();
count = 0;
//wxWidgets default wxMenuItem example
menu1->Append(wxID_ANY, _("&New\tCtrl+N" ));
menu1->Append(wxID_ANY, _("&Open\tCtrl+O" ));
menu1->Append(wxID_ANY, _("&Save\tCtrl+S" ));
menu1->Append(wxID_ANY, _("&Quit\tCtrl+Q" ));
menuBar->Append(menu1, _("&File" ));
SetMenuBar(menuBar);
SetBackgroundColour(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW));
buttonAdd = new wxButton (this, wxID_ANY, wxT("+"), wxPoint(24, 24), wxSize(24, 24));
buttonSub = new wxButton (this, wxID_ANY, wxT("-"), wxPoint(48, 24), wxSize(24, 24));
label = new wxStaticText(this, wxID_ANY, wxT("" ), wxPoint(72, 24), wxSize(24, 96));
Connect(buttonAdd->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainWindow::ButtonAddClicked));
Connect(buttonSub->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainWindow::ButtonSubClicked));
}
MainWindow::~MainWindow()
{
}
void MainWindow::ButtonAddClicked(wxCommandEvent & WXUNUSED(event))
{
count++;
label->SetLabel(wxString::Format(wxT("%d"), count));
}
void MainWindow::ButtonSubClicked(wxCommandEvent & WXUNUSED(event))
{
count--;
label->SetLabel(wxString::Format(wxT("%d"), count));
}
can someone explain to me whats wrong?