请教这样释放内存的析构函数有效吗
class List{
public:
List();
~List();
。。。。
private:
Node* Listhead;
Node* Current_Pos;
int X;
};
List::List()
{
Listhead=0;
Current_Pos=0;
}
List::~List()
{
Node* ptr = new Node;
ptr = Current_Pos;
while(Current_Pos!=0)
{
Current_Pos = Current_Pos->the_rest;
delete ptr;
ptr = Current_Pos;
}
delete Listhead;
delete Current_Pos;
}