关于继承中的虚函数的问题
当在主函数中定义一个指向派生类的基类指针时,为什么不能在基类中将构造函数声明为虚函数?详细的可以看下面的程序:#include<iostream>
using namespace std;
class point
{
public:
virtual point()
{
cout<<"huang"<<endl;
}
virtual ~point()
{
cout<<"executing point destructor "<<endl;
}
};
class circle :public point
{
public:
virtual circle (double r):radius(r)
{}
~circle ()
{
cout<<"executing circle destructor"<<endl;
}
private:
double radius ;
};
int main()
{
point *p=new circle (10);
delete p;
}
为什么编译会出错?