虚函数实现
http://www.cppblog.com/xczhang/archive/2008/01/20/41508.html
#include <iostream> #include <stdio.h> using namespace std; class Base1 { public: virtual void base1VirtualFun(int) { cout << "baseVirtualFun(float) in Base1" << endl; } }; class Base2 { public: virtual void base2VirtualFun(int) { cout << "baseVirtualFun(float) in Base2" << endl; } }; class Derived:public Base1, public Base2 { }; int main() { Base1 b1; Derived d; cout << sizeof(b1) << endl; cout << sizeof(d) << endl; return 0; }
结果:
4
8