如何释放二维指针!
class MyProgram:public Application
{
public:
MyProgram();
~MyProgram();
double run();
private:
shape **s;
};
MyProgram::MyProgram()
{
s=new shape *[];
s[0]=new Triangle(3.0,4.0);
s[1]=new Circle(6.5);
s[2]=new Rectangle(6.0,8.0);
s[3]=new Trapezoid(10.0,8.0,5.0);
s[4]=new square(6.7);
}
MyProgram::~MyProgram()
{ cout<<"k;lgsdfjgskldfjgsk;ldfgjdf";
for(int i=0;i<5;i++)
delete s[i];
delete[] s;
}
///例中的S如何释放,为什么这样释放老师出错