帮忙看看这两题
1.这题会造成内存泄漏吗??(p只是指向基类子对象)
#include<iostream.h>
class test
{
int a;
public:
~test()
{
cout<<"unload test\n";
}
};
class test1:public test
{
public:
int a;
test1()
{
a=100;
}
~test1()
{
cout<<"unload test1\n";
}
};
void main()
{
test *p=new test1;
delete p;
}
输出:unload test
2.为什么静态成员函数不可以被设置为虚拟的??(请大侠详解一下)