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????



LinkBack URL
About LinkBacks



, but of course when I try to implement it it doesn´t work!!!