《C&C++完美演绎》源代码

源代码在线查看: 18-5.txt

软件大小: 126 K
上传用户: a22aa11a
关键词: 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* 范例:18-5 */
				#include 
				class Base
				{
				  public:
				    virtual void fun1(){ cout 				    void fun2(){ cout 				};
				class Derived:public Base
				{
				  public:
				    void fun1(){ cout 				    void fun2(){ cout 				};
				void main()
				{
				  Derived  *obj_Derived = new Derived ;
				  Base     *obj_Base    = new Derived ;
				  obj_Base->fun1();  	/* 调用Derived::fun1(),依照链接 */
				  obj_Base->fun2();  	/* 调用Base::fun2()   */
				  obj_Derived->fun1(); 	/* 调用Derived::fun1(),依照链接 */
				  obj_Derived->fun2(); 	/* 调用Derived::fun2() */
				  delete obj_Base;
				  delete obj_Derived;
				  getchar();
				}
				
				程序执行结果:
				Derived::fun1
				Base::fun2
				Derived::fun1
				Derived::fun2
				
							

相关资源