Show using C++11 lambda in the "Hello world" example
This is so useful, that it should be mentioned even on this introductory page.
This commit is contained in:
@@ -209,6 +209,17 @@ void MyFrame::OnHello(wxCommandEvent& event)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
@note In C++11 programs, it can be convenient to use unnamed lambdas instead of
|
||||||
|
functions for event handlers, especially when handling events from the
|
||||||
|
controls as this allows to keep the code creating the control and handling
|
||||||
|
its event together in the same place. Here, for example, we could replace
|
||||||
|
the wxID_EXIT handler with just
|
||||||
|
|
||||||
|
@code
|
||||||
|
Bind(wxEVT_MENU, [=](wxCommandEvent&) { Close(true); }, wxID_EXIT);
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
Here is the entire program that can be copied and pasted:
|
Here is the entire program that can be copied and pasted:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
Reference in New Issue
Block a user