#include "stdafx.h"
#include<iostream>
using namespace std;
class A
{
public:
A()
{
cout<<"This is A/n";
}
protected:
private:
};
class B: public A
{
public:
B()
{
cout<<"This is B/n";
}
};
int _tmain(int argc, _TCHAR* argv[])
{
A*pa = new B; 這裏只申明A類型的指針不會調用A的構造函數,但是 new B的時候就會先調用A的構造函數,再調用B的構造函數。
//A a;
//B b;
system("pause");
return 0;
}