hafez1
جمعه 22 اردیبهشت 1391, 18:55 عصر
یه کلاسه تو نوشتن deconstructor اون اشکال دارم.
واسه deconstructor باید لینک لیست ایجاد شده در constructor رو حذف کنم.
این constructor کلاسمه:
template <class Type>
Stack<Type> :: Stack(int tol) //
{
stack <Type> *head = NULL;
stack <Type> *temp;
cout<<"tole morede nazar ra vared kon"<<"tol=";
cin>>tol;
head==NULL;
for(int i=0;i<tol;i++)
{
Type data;
cout<<"dade ra vared konid"<<"data=";
cin>>data;
temp=new stack;
temp->info=data;
temp->next=null;
if(head==NULL)
{
head=temp;
}
else
{
temp->next=head;
head=temp;
}
}
}
واسه deconstructor کمکم کنید.
واسه deconstructor باید لینک لیست ایجاد شده در constructor رو حذف کنم.
این constructor کلاسمه:
template <class Type>
Stack<Type> :: Stack(int tol) //
{
stack <Type> *head = NULL;
stack <Type> *temp;
cout<<"tole morede nazar ra vared kon"<<"tol=";
cin>>tol;
head==NULL;
for(int i=0;i<tol;i++)
{
Type data;
cout<<"dade ra vared konid"<<"data=";
cin>>data;
temp=new stack;
temp->info=data;
temp->next=null;
if(head==NULL)
{
head=temp;
}
else
{
temp->next=head;
head=temp;
}
}
}
واسه deconstructor کمکم کنید.