#include <stdio.h> class A { A() { printf("A constrution.\n"); } ~A() { printf("A deconstrution.\n"); } void funA(); virtual void funB(); }; void A::funA() { printf("A::funA ...\n"); } void A::funB() { printf("A::funB ...\n"); } class B : public A { public: B() { printf("B constrution.\n"); } ~B() { printf("B deconstrution.\n"); } void funA(); virtual void funB(); }; void B::funA() { printf("B::funA ...\n"); } void B::funB() { printf("B::funB ...\n"); } void main() { A *a = new B(); B b; a- (); a->funB(); b.funA(); b.funB(); delete a; }
写出输出结果:(呵呵,顺便复习一下g++的编译的几个步骤)
时间: 2024-11-12 07:24:34