前回いまさらwindowsプログラミング - while( c++ );のプログラムにリスナを追加してみます。 今日の目標 WindowListenerインターフェイスを実装した派生クラスをウィンドウに追加する。 WindowClosing()でSystem::Exit()を呼び出すと、プログラムが終了する。 class HogeWindowListener : public WindowListener { public: //×ボタンを押したときの処理 void WindowClosing( WindowEvent& e ) { //プログラム終了 System::Exit( 0 ); std::cout << "closing" << std::endl; } }; int main() { std::cout << "start" << std::endl; //デフォルトのプロシ
![C++でjava風リスナを実装する - while( c++ );](https://cdn-ak-scissors.b.st-hatena.com/image/square/a3f33900772c296b479a818bbead34e55d2b2875/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fs%2Fsetuna-kanata%2F20081208%2F20081208042132.jpg)