template <class Node> class ListManager
{
private:
ListManager <Node> * startPtr;
public:
ListManager(){ startPtr = NULL;};
~ListManager();
unsigned short Menu(unsigned short);
bool AddNode ();
bool UpdateNode (Node *Ptr, string key);
bool ViewNode (Node *Ptr, string key);
bool DeleteNode (Node *Ptr, string key);
bool ViewAllNode (Node *Ptr);
};
bool ListManager<Node>::AddNode()
{
ListManager<Node> * newNode = new ListManager<Node>();
ListManager<Node> * currentPtr;
if (startPtr == NULL)
startPtr = newNode;
else
{
currentPtr = startPtr;
while (currentPtr->GetNextPtr() != NULL)
currentPtr = currentPtr->GetNextPtr();
currentPtr = newNode;
}
return true;
}
int main ()
{
ListManager<Employee> *head = new ListManager<Employee>();
head->AddNode(); //produces an error "GetNextPtr" not a member of ListManager<Node>
head->Menu(); //Works just fine
return 0;
}
Singly Linked List in C++
Page 1 of 11 Replies - 1621 Views - Last Post: 07 March 2010 - 07:45 PM
#1
Singly Linked List in C++
Posted 07 March 2010 - 07:13 PM
Im trying to implement a singly linked list for my school project. If i try to add a node in the driver i get an error message that "GetNextPtr" is not a member of ListManager<Node>. GetNextPtr is actually a member in the node classes so i would like to know how to implement ListManager to access the functions in the node class (Whenever i create a ListManager of type Employee or Department). Im using vc++ 2008 express ed, any help would be greatly appreciated.
Replies To: Singly Linked List in C++
Page 1 of 1

New Topic/Question
Reply


MultiQuote



|