Will someone help me out in building a link list with a tail and header pointers?
I did google, but i couldnt find anything useful.
now if i want to build a list with my head and tail pointers i would do this?Code:struct Node { Nutricalc Data; Node* next; }; class FoodLists { public: // constructors FoodLists(); FoodLists(char fileName[]); FoodLists(int initCapacity); FoodLists(const FoodLists& aList); // member functions void deletefood(int index); void addFood(const Nutricalc &aFood); void listFood(); bool searchByName(char title[], Nutricalc& afood) const; bool searchByCategory(Category cat, FoodLists & food) const; int getSize()const; void writeOut(char fileName[]) const; // destructor ~FoodLists(); private: //data members Node * head; Node * tail; int size; / void addAtBeginning(const Nutricalc& afood); void addAtEnd(const Nutricalc& afood); //void addSorted(const Nutricalc& afood); };
head = tail;
tail->next = new Node; // or NULL?
tail = tail->next;
will that give me an empty list using the class FoodLists tail and head pointer?
any help is much appreciated!
Corey