引用块内容
include
using namespace std;
class A { public: A() { cout << “A constrution” << endl; } ~A() { cout << “A deconstrution” << endl; } void funA() { cout << “A::funA…” << endl; } virtual void funB() { cout << ” A::funB…” << endl; } };
class B : public A { public: B() { cout << “B constrution” << endl; } ~B() { cout << “B deconstrution” << endl; } void funA() { cout << “B::funA…” << endl; } virtual void funB() { cout << “B::funB…” << endl; }
};
int main() { A *a = new B(); B b; a->funA();//为什么?? a->funB(); b.funA(); b.funB(); delete a; //system(“pause”); return 0; }