虚函数实现

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

posted @ 2013-04-26 11:15  helloweworld  阅读(141)  评论(0编辑  收藏  举报