virtual function and pure virtual function please refer to: http://blog.csdn.net/hackbuteer1/article/details/7558868
#include <iostream>using namespace std;class Animal{public: Virtual void eat () =0; virtual void sleep () = 0;}; Class cat:public animal{public: void eat () { cout<< "The cat is eating now." <<endl; } void sleep () { cout<< "The cat is sleeping now." <<endl; }};class bear:public animal{public: void eat () { cout<< "The bear is eating now. " <<endl; } void sleep () { cout<< "The bear is sleeping now." <<endl; }};class Panda:public Cat,public Bear{public: void eat () { cout< < "The panda is eating now." <<endl; } void sleep () { cout<< "The panda is sleeping now." <<endl; }};void show (cat *p) { cout<< "===== =================== "<<endl; p->eat (); p->sleep (); cout<< "========================" <<ENDL;} Int main (int argc, char *argv[]) { cat *p; Cat c; Panda d; p=&c; show (p); p=&d ; show (P); return 0;}
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/A5/07/wKioL1m2eJbALSuHAAA0tYuK5kE441.png-wh_500x0-wm_ 3-wmp_4-s_32485604.png "title=" 111.png "alt=" Wkiol1m2ejbalsuhaaa0tyuk5ke441.png-wh_50 "/>
This article is from the "10628473" blog, please be sure to keep this source http://10638473.blog.51cto.com/10628473/1964428
Examples of C + + abstract class and pure virtual function combat