Hello
I tried to delete all the Linked List
But I can not so
Is there a way to delete the all Linked List?
struct input
{
int id;
struct input * next;
};
typedef struct input ie;
class input_events
{
typedef struct input ie;
private:
ie *l;
public:
~input_events();
input_events();
void add_ie(ie *p);
void gener_ie();
};
input_events :: ~input_events()
{
typedef struct input ie;
ie * ptr;
ie * qtr;
ptr = l;
qtr = l->next;
while (ptr)
{
delete ptr;
ptr = qtr;
if (! qtr)
{
qtr = qtr->next;
}
}
}
ie * ine;
ine = new ie;
ine->id = 1;
ptr_ie->add_ie(ine);
ine->id = 2;
ptr_ie->add_ie(ine);
ine->id = 3;
ptr_ie->add_ie(ine);
ine->id = 4;
ptr_ie->add_ie(ine);
ine->id = 5;
ptr_ie->add_ie(ine);
cout << "*************** \n";
cout << "Input is : \n";
cout << "*************** \n";
ptr_ie->gener_ie();
ptr_ie->~input_events(); // Dellet All Linked list
cout << "*************** \n";
cout << "Input is : \n";
cout << "*************** \n";
ptr_ie->gener_ie();
Thank you....