According to the csdn Liu Wei technology blog, the C ++ command mode example is as follows:
1 // include/command. H 2 3 # ifndef _ command _ 4 # DEFINE _ command _ 5 6 # include <define whandler. h> 7 # include
1 // include/functionbutton. H 2 3 # ifndef _ fucnctionbutton _ 4 # DEFINE _ fucnctionbutton _ 5 6 # include <command. h> 7 // function key class: Request sender 8 class functionbutton 9 {10 private: 11 char * Name; // function key name 12 Command * command; // maintain an abstract command object pointer 13 14 public: 15 functionbutton (const char * Str); 16 17 const char * getname (void) const; 18 19 // For function key injection command 20 void setcommand (command * cmd); 21 22 // Method for sending request 23 void onclick (void); 24 2 5 ~ Functionbutton (void); 26}; 27 28 # endif
1 // include/functionbutton. H 2 3 # ifndef _ fucnctionbutton _ 4 # DEFINE _ fucnctionbutton _ 5 6 # include <command. h> 7 // function key class: Request sender 8 class functionbutton 9 {10 private: 11 char * Name; // function key name 12 Command * command; // maintain an abstract command object pointer 13 14 public: 15 functionbutton (const char * Str); 16 17 const char * getname (void) const; 18 19 // For function key injection command 20 void setcommand (command * cmd); 21 22 // Method for sending request 23 void onclick (void); 24 2 5 ~ Functionbutton (void); 26}; 27 28 # endif
1 // include/fbsettingwindow. H 2 3 # ifndef _ fbsettingwindow _ 4 # DEFINE _ fbsettingwindow _ 5 6 # include <functionbutton. h> 7 // function settings window class 8 class fbsettingwindow 9 {10 private: 11 char * title; // window title 12 // define an arraylist to store all function keys 13 functionbutton * functionbuttons [16]; 14 15 public: 16 fbsettingwindow (void ); 17 18 fbsettingwindow (const char * Str); 19 20 void settitle (const char * Str); 21 22 const char * gettit Le (void) const; 23 24 void addfunctionbutton (functionbutton * FB); 25 26 void removefunctionbutton (functionbutton * FB ); 27 28 // display window and function key 29 void display (void); 30 31-30 ~ Fbsettingwindow (void); 32 33}; 34 # endif
1 // include/helphandler. H 2 3 # ifndef _ helphandler _ 4 # DEFINE _ helphandler _ 5 6 // help document processing class: Request recipient 7 class helphandler 8 {9 public: 10 void display (void); 11}; 12 13 # endif
1 // include/define whandler. H 2 3 # ifndef _ DEFINE whandler _ 4 # DEFINE _ DEFINE whandler _ 5 6 7 // window processing class: Request receiver 8 class program whandler 9 {10 public: 11 void minimize (void); 12}; 13 14 # endif