Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Interface{
- public:
- Interface(){};
- virtual States Action(States s, uint8_t key) = 0;
- virtual uint8_t ReadKey() = 0;
- };
- class ob : public Interface{
- public:
- ob(){
- Text.ClrScr();
- Text.GoTo(0,0);
- Text.Write("constructor ob \n");
- };
- virtual States Action(States s, uint8_t key){
- Text.ClrScr();
- Text.GoTo(0,0);
- Text.Write("ob override Action\n");
- return sInputWindow;
- };
- virtual uint8_t ReadKey(void){
- return 'b';
- };
- };
- class oa : public Interface {
- public:
- oa(){
- Text.ClrScr();
- Text.GoTo(0,0);
- Text.Write("constructor oa \n");
- };
- virtual States Action(States s, uint8_t key){
- Text.ClrScr();
- Text.GoTo(0,0);
- Text.Write("oa override Action\n");
- return sMainWindow;
- };
- virtual uint8_t ReadKey(void){
- return 'a';
- };
- };
- int main(void)
- {
- oa a;
- ob b;
- States s = sMainWindow;
- Interface* obj;
- obj = &a;
- while(1){
- s = obj->Action(s, obj->ReadKey());
- if( s == sMainWindow){
- obj = &b;
- }else{
- obj = &a;
- }
- delay(0x2fffff);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment