Using the Win32 console program and the boost: signals2 library, you can also write interesting demo games.
Post the code first and then explain it:
# Include "stdafx. H "<br/> # include <iostream> <br/> # include <boost/signals2.hpp> <br/> using namespace STD; <br/> typedef int status; <br/> Status capriconstation (const int power, const int enhancefactor) <br/>{< br/> If (power> = 10) <br/> {<br/> int nnewpower = power * enhancefactor; <br/> cout <"your power has alreay been enhaned by capriconstation, now is: "<nnewpower <Endl; <br/> return 1; <br/>}< br/> Else <br/> {<br/> cout <"capriconstation cannot enhance your power, please goto next station! /N "; <br/> return 0; <br/>}< br/> Status scorpiostation (const int power, const int enhancefactor) <br/>{< br/> If (power> 0 & Power <10) <br/>{< br/> int nnewpower = power * enhancefactor; <br/> cout <"your power has alreay been enhaned by scorpiostation, now is:" <nnewpower <Endl; <br/> return 1; <br/>}< br/> else <br/> {<br/> cout <"scorpiostation cannot enhance your power, please goto next stat Ion! /N "; <br/> return 0; <br/>}< br/> Status recyclestation (const int power, const int enhancefactor) <br/> {<br/> If (power <0) <br/> {<br/> cout <"your left power is not normal! You are recycled by recyclestation! /N "; <br/> cout <" you are dead! /N "; <br/> return 0; <br/>}< br/> // combiner: distributerequestsystem <br/> typedef int fullfilledrequest; <br/> struct distributerequestsystem <br/>{< br/> typedef fullfilledrequest result_type; <br/> template <typename inputiter> <br/> result_type operator () (inputiter first, inputiter last) <br/>{< br/> while (first! = Last) <br/>{< br/> If (nsuccessstatus = * First) <br/> return nsuccessstatus; <br/> + first; <br/>}< br/> return 0; <br/>}< br/> const static int nsuccessstatus = 1; <br/> }; <br/> int main () <br/> {<br/> boost: signals2: Signal <int (const int, const INT), distributerequestsystem> sig_5; <br/> sig_5.connect (& capriconstation); <br/> sig_5.connect (& scorpiostation); <br/> sig_5.connect (& recyclestation ); <br/> cout <"the responding status:" <sig_5 (8, 5) <Endl; <br/> cout <"the responding status: "<sig_5 () <Endl; <br/> cout <" the responding status: "<sig_5 (-) <Endl; <br/> return 0; <br/>}
Running result: