# Include <iostream> # include <string> # include <vector> using namespace STD; Class commandbase {public: Virtual void run () = 0; private :}; class command1: public commandbase {public: command1 (string strname): m_strname (strname) {}; void run () {cout <m_strname <Endl;} PRIVATE: String m_strname ;}; class command2: Public commandbase {public: command2 (string strname): m_strname (strname) {}; void run () {cout <m_strname <End L;} PRIVATE: String m_strname;}; Class command3: Public commandbase {public: command3 (string strname): m_strname (strname) {}; void run () {cout <m_strname <Endl;} PRIVATE: String m_strname;}; Class exclude {public: void add (commandbase & command) {m_vetorcommand.push_back (& command );} void run () {vector <commandbase *>: iterator itr = m_vetorcommand.begin (); While (itr! = M_vetorcommand.end () {(* itr ++)-> Run () ;}} PRIVATE: vector <commandbase *> m_vetorcommand; static exclude m_cexclude ;}; int main () {command1 ccommand1 ("cmd1"); command2 ccommand2 ("cmd2"); command3 ccommand3 ("cmd3"); Exclude cexclude; cexclude. add (ccommand1); cexclude. add (ccommand2); cexclude. add (ccommand3); cexclude. run (); While (1 );}