Iīm currently working on a phonebook and Iīm trying to create a unique ID number for each entry. It looks something like this...
I have stored all entries in a double linked list because I don't know how many entries the user is gonna input. The problem is is when an entry gets deleted that corresponing ID number is lost.Code:class Person
{
public:
Person(){itsId = id++;}
~Person();
............
.............
void SetNext(Person *setlink) {next = setlink;}
void SetPrevious(Person *setlink) {previous = setlink;}
Person* GetNext() const {return next;}
Person* GetPrevious() const {return previous;}
int getId() {return itsId;}
private:
static int id;
int itsId;
//For double-linked list
Person *next;
Person *previous;
};
int Person::id = 0;
Iīm trying to find a solution that I can reuse this "lost ID number", but so far havenīt been sucessful.
Any suggestion????