C + + virtual functions
In Smartos, the key word for virtual is the virtual function definition of C + +
The member function, which is modified by the keyword of virtual, is the virtual function
Virtual functions are redefined by the program when they are inherited, and when used, they are inherited by the same base class (parent Class) lock, their function names are the same, but their functions are different, and that is his polymorphism.
The polymorphism in object-oriented programming is to send the same message to different objects, and different objects produce different behaviors for the same message. In the program, the message is called the function, the different behavior refers to the different implementation method, namely executes the different function body. It can also be said that the implementation of "one interface, a variety of methods."
1 protected:2Gpio_inittypedef Gpio;//struct-Body object for configuring ports3 4 Port ();5 Virtual~Port ();6 7 voidSetport (PIN pin);//Single PIN initialization8 voidSetport (Pin pins[],UINTcount);//initialized with a set of pins, the PIN group Gpiox is determined by the first pin, make sure all pins are in the same group Gpiox9 voidSetport (gpio_typedef* Group,ushortPinbit =gpio_pin_all);Ten One //configuration process, called by Config, and finally Gpio_init A Virtual voidOnConfig ();
------virtual function of C + +