#include "stdafx.h"
#include<iostream>
using namespace std;
class A
{public:
A(){cout<<"A的构造函数";foo();}
~A(){}
virtual void foo(){cout<<"A::foo"<<endl;}
};
class B:public A
{public:
B(){cout<<"B的构造函数";foo();}
~B(){}
virtual void foo(){cout<<"B::foo"<<endl;}
};
int _tmain(int argc, _TCHAR* argv[])
{
A b, *a=new B();
delete a;
return 0;
}
求教第三行啥意思。
#include<iostream>
using namespace std;
class A
{public:
A(){cout<<"A的构造函数";foo();}
~A(){}
virtual void foo(){cout<<"A::foo"<<endl;}
};
class B:public A
{public:
B(){cout<<"B的构造函数";foo();}
~B(){}
virtual void foo(){cout<<"B::foo"<<endl;}
};
int _tmain(int argc, _TCHAR* argv[])
{
A b, *a=new B();
delete a;
return 0;
}
求教第三行啥意思。