<span style="font-size:18px;">#include <iostream>
using namespace std ; 
class   AA 
{
	public:
		int a ;
		//虚函数
		virtual void say_hello(void)
		{
			cout << "this is your parent " << endl ; 
		}
};
class  BB : public  AA
{
	public:
		int b ; 
//如果子类没有实现虚函数,则多态中会调用父类的虚函数
//如果子类有重新实现虚函数,则多态中会调用子类的虚函数 
//__weak   相似
//		void say_hello(void)
//		{
//			cout << "this is your son " << endl ; 
//		}
};
int main(void)
{
	BB bb ; 
	AA * aa = NULL ;
	aa =  (AA *)&bb ; 
	aa->say_hello();
	
	return  0 ; 
}
</span>
运行结果:
原文:http://blog.csdn.net/morixinguan/article/details/50880822