How to clear the filled list in C ++? That created an empty class. I start to fill it with a certain function, and now I need to reset it? Will you help with the function? Here is the class itself:
#include <iostream> #include <conio.h> #include <string.h> using namespace std; struct element { string data; element *adress; }; class List { private: element * StartAdress, *FinishAdress; public: List() { StartAdress = NULL; FinishAdress = NULL; } void ElAdd(string a) { element *e; e = new element; e->data = a; if (StartAdress == NULL) { StartAdress = e; } else { FinishAdress->adress = e; } FinishAdress = e; FinishAdress->adress = NULL; } void print() { element *e; for (e = StartAdress; e != NULL; e = e->adress) cout << e->data << " " << endl; } };
I myself thought that:
void ElDel (string a) { StartAdress == NULL; FinishAdress == NULL; }
But it seems not worked. Tell me?