So I'm trying to make a templated linked list class. I have the node.h, node.template [which has the implementations for the node member functions], linkedList.h, and linkedList.template [containing linked list template functions]. Problem is with the linkedList file. It is designed to take the place of having a linked list toolkit function set, or something where the actual implementations would be visible, and instead takes the node and encapsulates it within its own object. I have functions for inserting and removing nodes. For the removal, each function can either remove the node/eturn nothing, return the data as a reference, return the data as a pointer, return the node as a reference, or return the node as a pointer. I have the definitions down, and have empty shells - functions that have no code within them - in the implementation files as I haven't gotten to them yet. When I try to instantiate a linked list [and just instantiate it, do nothing to it yet since the functions haven't been fully implemented yet, these errors occur: ../linkedList.h: In instantiation of 'tLinkedList::linkedList<int>': ../main.cpp:11: instantiated from here ../linkedList.h:302: error: 'tNode::node<nData>* tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' cannot be overloaded ../linkedList.h:295: error: with 'void tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' ../linkedList.h:309: error: 'tNode::node<nData> tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' cannot be overloaded ../linkedList.h:295: error: with 'void tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' ../linkedList.h:317: error: 'nData* tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' cannot be overloaded ../linkedList.h:295: error: with 'void tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' ../linkedList.h:324: error: 'nData tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' cannot be overloaded ../linkedList.h:295: error: with 'void tLinkedList::linkedList<nData>::removeAtHead() [with nData = int]' ../linkedList.h:342: error: 'tNode::node<nData>* tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' cannot be overloaded ../linkedList.h:333: error: with 'void tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' ../linkedList.h:351: error: 'tNode::node<nData> tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' cannot be overloaded ../linkedList.h:333: error: with 'void tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' ../linkedList.h:360: error: 'nData* tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' cannot be overloaded ../linkedList.h:333: error: with 'void tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' ../linkedList.h:369: error: 'nData tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' cannot be overloaded ../linkedList.h:333: error: with 'void tLinkedList::linkedList<nData>::removeAtTail() [with nData = int]' ../linkedList.h:387: error: 'tNode::node<nData>* tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' cannot be overloaded ../linkedList.h:378: error: with 'void tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' ../linkedList.h:396: error: 'tNode::node<nData> tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' cannot be overloaded ../linkedList.h:378: error: with 'void tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' ../linkedList.h:405: error: 'nData* tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' cannot be overloaded ../linkedList.h:378: error: with 'void tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' ../linkedList.h:414: error: 'nData tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' cannot be overloaded ../linkedList.h:378: error: with 'void tLinkedList::linkedList<nData>::removeAtPos(size_t) [with nData = int]' What the hell is going on? node.h Spoiler Code (Text): // Begin file node.h // Preprocessor Directives: // Defining NODE_H to prevent naming conflicts #ifndef NODE_H #define NODE_H // Libraries needed: #include <cstdlib> // End preprocessor directives // Begin encapsulation into namespace tNode namespace tNode { // Begin class definition // Being a templated class, the "type" template name will be nData template <typename nData> class node { // DATA: private: node * next; // A pointer to a node representative of the // next node in a linked list node * prev; // A pointer to a node representative of the // previous node in a linked list nData data; // The data held in the node, uses template // typename nData // MEMBER FUNCTIONS: public: // CONSTRUCTORS: // Constructor node(); // PRE: None // POST: Creates a new node: // -- Next, prev [Node pointers] set to NULL // -- No value given for data; node(); // Constructor node(const nData inData); // PRE: Accepts a const nData inData // POST: Creates a new node: // -- Next, prev [Node pointers] set to NULL // -- Data is set to inData node(const nData inData); // COPY Constructor node(const node<nData> & inCopy); // PRE: Accepts a const reference node inCopy // POST: Creates a new node: // -- Sets next to inCopyNode's next node // -- Sets prev to inCopyNode's prev node // -- Sets data to incopyNode's data value node(const node<nData> & inCopy); // COPY Constructor node(const node<nData> & inCopy); // PRE: Accepts a const node pointer inCopy // POST: Creates a new node: // -- Sets next to inCopyNode's next node // -- Sets prev to inCopyNode's prev node // -- Sets data to incopyNode's data value node(const node<nData> * inCopy); // Constructor node(const node<nData> * inNext, const node<nData> * inPrev); // PRE: Accepts a const node pointer inNext, and a const node pointer inNext, // POST: Creates a new node: // -- Sets next inNext // -- Sets prev to inPrev node(const node<nData> * inNext, const node<nData> * inPrev); // Constructor node(const node<nData> * inNext, const node<nData> * inPrev, const nData & inData); // PRE: Accepts a const node pointer inNext, a const node pointer inNext, and a const nDatareference inData // POST: Creates a new node: // -- Sets next inNext // -- Sets prev to inPrev // -- Sets data to inData node(const node<nData> * inNext, const node<nData> * inPrev, const nData & inData); // DESTRUCTORS: // Destructor ~node(); // PRE: None // POST: Free the memory taken up by the node instance's // prev / next node pointers ~node(); // ACCESSORS: // Accessor getNext() const; // PRE: None // POST: Returns next as a const node pointer node<nData> * getNext() const; // ACCESSORS: // Accessor getPrev() const; // PRE: None // POST: Returns prev as a const node pointer node<nData> * getPrev() const; // ACCESSORS: // Accessor getData() const; // PRE: None // POST: Returns data as const nData nData getData() const; // MUTATORS: // Mutator setNext(const node<nData> * inNext); // PRE: Accepts a const node pointer inNext // POST: Sets next to inNext void setNext(const node<nData> * inNext); // Mutator setPrev(const node<nData> * inPrev); // PRE: Accepts a const node pointer inPrev // POST: Sets prev to inPrev void setPrev(const node<nData> * inPrev); // Mutator setData(const nData & inData); // PRE: Accepts const nData reference inData // POST: Sets data to inData void setData(const nData & inData); // Mutator setData(const nData * inData); // PRE: Accepts const nData pointer inData // POST: Sets data to inData void setData(const nData * inData); // OVERLOADED OPERATORS: // operator=(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: Sets this node so: // -- next = inNode's next node // -- prev = inNode's prev node // -- data = inNode's data value void operator=(const node<nData> * inNode); // operator=(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: Sets this node so: // -- next = inNode's next node // -- prev = inNode's prev node // -- data = inNode's data value void operator=(const node<nData> & inNode); // operator==(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: Compares the data value of this node instance and inNode // -- Returns true if they are equal // -- Returns false if they are not bool operator==(const node<nData> * inNode); // operator==(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: Compares the data value of this node instance and inNode // -- Returns true if they are equal // -- Returns false if they are not bool operator==(const node<nData> & inNode); // operator+=(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: If this instance's next node is NULL and inNode isn't // the same as this node instance, set next to inNode void operator+=(const node<nData> * inNode); // operator+=(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: If this instance's next node is NULL and inNode isn't // the same as this node instance, set next to inNode void operator+=(const node<nData> & inNode); }; // End encapsulation into namespace tNode } // Include "node.template," which includes the function implementations for the // node class's member functions #include "node.template" // End definition of NODE_H #endif // End file node.h node.template Spoiler Code (Text): // Begin file node.template // Preprocessor Directives: // Include node.h to get class, class member function definitions #include "node.h" // End preprocessor directives // Begin encapsulation into namespace tNode namespace tNode { // Begin member function implementations // CONSTRUCTORS: // Constructor node(); // PRE: None // POST: Creates a new node: // -- Next, prev [Node pointers] set to NULL // -- No value given for data; template <typename nData> node<nData>::node() { next = NULL; // Set next to NULL prev = NULL; // Set prev to NULL } // Constructor node(const nData inData); // PRE: Accepts a const nData inData // POST: Creates a new node: // -- Next, prev [Node pointers] set to NULL // -- Data is set to inData template <typename nData> node<nData>::node(const nData inData) { next = NULL; // Set next to NULL prev = NULL; // Set prev to NULL data = inData; // Set data to inData } // COPY Constructor node(const node<nData> & inCopy); // PRE: Accepts a const reference node inCopy // POST: Creates a new node: // -- Sets next to inCopyNode's next node // -- Sets prev to inCopyNode's prev node // -- Sets data to incopyNode's data value template <typename nData> node<nData>::node(const node<nData> & inCopy) { next = inCopy.getNext(); // Set next to inCopy's next node prev = inCopy.getPrev(); // set prev to inCopy's prev node data = inCopy.getData(); // Set data to inCopy's data value } // COPY Constructor node(const node<nData> & inCopy); // PRE: Accepts a const node pointer inCopy // POST: Creates a new node: // -- Sets next to inCopyNode's next node // -- Sets prev to inCopyNode's prev node // -- Sets data to incopyNode's data value template <typename nData> node<nData>::node(const node<nData> * inCopy) { next = inCopy->getNext(); // Set next to inCopy's next node prev = inCopy->getPrev(); // set prev to inCopy's prev node data = inCopy->getData(); // Set data to inCopy's data value } // Constructor node(const node<nData> * inNext, const node<nData> * inPrev); // PRE: Accepts a const node pointer inNext, and a const node pointer inNext, // POST: Creates a new node: // -- Sets next inNext // -- Sets prev to inPrev // -- Nothing is done to data template <typename nData> node<nData>::node(const node<nData> * inNext, const node<nData> * inPrev) { next = inNext; // Set next to inNext prev = inPrev; // Set prev to inPrev } // Constructor node(const node<nData> * inNext, const node<nData> * inPrev, const nData & inData); // PRE: Accepts a const node pointer inNext, a const node pointer inNext, and a const nDatareference inData // POST: Creates a new node: // -- Sets next inNext // -- Sets prev to inPrev // -- Sets data to inData template <typename nData> node<nData>::node(const node<nData> * inNext, const node<nData> * inPrev, const nData & inData) { next = inNext; // Set next to inNext prev = inPrev; // Set prev to inPrev data = inData; // Set data to inData } // DESTRUCTORS: // Destructor ~node(); // PRE: None // POST: Free the memory taken up by the node instance's // prev / next node pointers template <typename nData> node<nData>::~node() { // Free up the memory used by next delete next; next = NULL; // Free up the memory used by prev delete prev; prev = NULL; } // ACCESSORS: // Accessor getNext() const; // PRE: None // POST: Returns next as a const node pointer template <typename nData> node<nData> * node<nData>::getNext() const { // Return next; return next; } // Accessor getPrev() const; // PRE: None // POST: Returns prev as a const node pointer template <typename nData> node<nData> * node<nData>::getPrev() const { // Return prev; return prev; } // Accessor getData() const; // PRE: None // POST: Returns data as const nData template <typename nData> nData node<nData>::getData() const { // Return data; return data; } // MUTATORS: // Mutator setNext(const node<nData> * inNext); // PRE: Accepts a const node pointer inNext // POST: Sets next to inNext template <typename nData> void node<nData>::setNext(const node<nData> * inNext) { // Set next to inNext next = inNext; } // Mutator setPrev(const node<nData> * inPrev); // PRE: Accepts a const node pointer inPrev // POST: Sets prev to inPrev template <typename nData> void node<nData>::setPrev(const node<nData> * inPrev) { // Set next to inPrev prev = inPrev; } // Mutator setData(const nData & inData); // PRE: Accepts const nData reference inData // POST: Sets data to inData template <typename nData> void node<nData>::setData(const nData & inData) { // Set data to inData data = inData; } // Mutator setData(const nData * inData); // PRE: Accepts const nData pointer inData // POST: Sets data to inData template <typename nData> void node<nData>::setData(const nData * inData) { // Set data to inData data = *(inData); } // OVERLOADED OPERATORS: // operator =(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: Sets this node so: // -- next = inNode's next node // -- prev = inNode's prev node // -- data = inNode's data value template <typename nData> void node<nData>::operator=(const node<nData> * inNode) { // Set next to inData's next node next = inNode->getNext(); // Set prev to inData's prev node prev = inNode->getPrev(); // Set data to inNode's data value data = inNode->getData(); } // operator =(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: Sets this node so: // -- next = inNode's next node // -- prev = inNode's prev node // -- data = inNode's data value template <typename nData> void node<nData>::operator=(const node<nData> & inNode) { // Set next to inData's next node next = inNode.getNext(); // Set prev to inData's prev node prev = inNode.getPrev(); // Set data to inNode's data value data = inNode.getData(); } // operator==(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: Compares the data value of this node instance and inNode // -- Returns true if they are equal // -- Returns false if they are not template <typename nData> bool node<nData>::operator==(const node<nData> * inNode) { // Return the boolean result of comparing data to inNode's data return (data == inNode->getData()); } // operator==(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: Compares the data value of this node instance and inNode // -- Returns true if they are equal // -- Returns false if they are not template <typename nData> bool node<nData>::operator==(const node<nData> & inNode) { // Return the boolean result of comparing data to inNode's data return (data == inNode.getData()); } // operator+=(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode as the righthand argument // POST: If this instance's next node is NULL and inNode isn't // the same as this node instance, set next to inNode template <typename nData> void node<nData>::operator+=(const node<nData> * inNode) { // If this's next node is not null, return if(next != NULL) { return; } // If inNode is this, return if(inNode == this) { return; } // Otherwise set this's next node to inNode next = inNode; } // operator+=(const node<nData> & inNode); // PRE: Accepts a const node reference inNode as the righthand argument // POST: If this instance's next node is NULL and inNode isn't // the same as this node instance, set next to inNode template <typename nData> void node<nData>::operator+=(const node<nData> & inNode) { if(next != NULL) { return; } if(inNode == this) { return; } next = new node<nData>(inNode); } // End class member function implementations // End encapsulation into namespace tNode } // End file node.template linkedList.h: Spoiler Code (Text): // Begin file "linkedList.h" // Begin preprocessor directives // Define LINKED_LIST_H to prevent naming conflicts #ifndef LINKED_LIST_H #define LINKED_LIST_H // Include libraries we may need: #include "node.h" // Using the tNode namespace since, even though we included node.h, we // need to explicitly say we need the node class encapsulated within it. using namespace tNode; // End preprocessor directives // Begin encapsulation into namespace tLinkedList namespace tLinkedList { // Begin class definition // Being a templated class, the "type" template name will be nData template <typename nData> class linkedList { // DATA: private: size_t maxCapacity; // The maximum capacity of the list size_t currCapacity; // The current capacity of the list bool isEmpty; // BOOLEAN FLAG: Is the list empty? bool isFull; // BOOLEAN FLAG: Is the list full? node<nData> * lHead; // The linked list head node node<nData> * lTail; // The linked list tail node // MEMBER FUNCTIONS: public: // CONSTRUCTORS: // Constructor linkedList() // PRE: None // POST: Create a new empty linked list: // -- lHead = NULL // -- lTail = NULL // -- maxCapacity = 0 // -- currCapacity = 0 // -- isEmpty = false // -- isFull = false linkedList(); // COPY constructor linkedList(const linkedList<nData> * inList) // PRE: Accepts const linkedList pointer inList // POST: Create a new linkedList: // -- lHead = inList's lHead // -- lTail = inList's lTail // -- maxCapacity = inList's maxCapacity // -- currCapacity = inList's currCapacity // -- isEmpty = inList's isEmpty // -- isFull = inList's isFull linkedList(const linkedList<nData> * inList); // COPY constructor linkedList(const linkedList<nData> & inList) // PRE: Accepts const linkedList reference inList // POST: Create a new linkedList: // -- lHead = inList's lHead // -- lTail = inList's lTail // -- maxCapacity = inList's maxCapacity // -- currCapacity = inList's currCapacity // -- isEmpty = inList's isEmpty // -- isFull = inList's isFull linkedList(const linkedList<nData> & inList); // Constructor node(const node<nData> * inlistHead) // PRE: Accepts const node pointer inList // POST: Creates a new linkList: // -- lHead = inHead // -- lTail, currCapacity,isFull, isEmpty is set // based on traversing inHead // -- maxCapacity is set to currCapacity linkedList(const node<nData> * inListHead); // Constructor node(const node<nData> & inlistHead) // PRE: Accepts const node reference inList // POST: Creates a new linkList: // -- lHead = inHead // -- lTail, currCapacity,isFull, isEmpty is set // based on traversing inHead // -- maxCapacity is set to currCapacity linkedList(const node<nData> & inListHead); // DESTRUCTORS: // Destructor ~linkedList() // PRE: None // POST: Deallocates, frees up memory allocated to listHead, listTail ~linkedList(); // ACCESSORS: // Accessor getMaxCapacity() const; // PRE: None // POST: Returns maxCapacity size_t getMaxCapacity() const; // Accessor getCurrCapacity() const; // PRE: None // POST: Returns currCapacity size_t getCurrCapacity() const; // Mutator calcCurrCapacity(); // PRE: None // POST: Calculate currCapacity void calcCurrCapacity(); // Accessor getIsEmpty() const; // PRE: None // POST: Returns isEmpty bool getIsEmpty() const; // Accessor getIsFull() const; // PRE: None // POST: Returns isFull bool getIsFull() const; // Accessor getListHead() const; // PRE: None // POST: Returns list head; NULL if it isn't instantiated to anything node<nData> * getListHead() const; // Accessor getListTail() const; // PRE: None // POST: Returns list head; NULL if it isn't instantiated to anything node<nData> * getListTail() const; // Accessor getData(const size_t inPos, const nData inData) const; // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity], accepts const // nData inData // POST: Traverses the list to find the data specified by nData // and returns it if it exists, returns NULL if it doesn't nData getData(const size_t inPos, const nData inData) const; // MUTATORS: // Mutator setMaxCapacity(const size_t inMaxCapacity); // PRE: Accepts a const size_t inMaxCapacity // POST: Sets maxCapacity to inMaxCapacity void setMaxCapacity(const size_t inMaxCapacity); // Mutator setCurrCapacity(const size_t inCurrCapacity); // PRE: Accepts a const size_t inCurrCapacity // POST: Returns currCapacity void setCurrCapacity(const size_t inCurrCapacity); // Mutator setIsEmpty(const bool inIsEmpty); // PRE: Accepts const bool inIsEmpty // POST: sets isEmpty to inIsEmpty; void setIsEmpty(const bool inIsEmpty); // Mutator calcIsEmpty(); // PRE: None // POST: Calculates / sets isEmpty void calcIsEmpty(); // Mutator setIsFull(const bool inIsFull); // PRE: Accepts const bool inIsFull // POST: Sets isFull to inIsFull void setIsFull(const bool inIsFull); // Mutator calcIsFull() // PRE: None // POST: Calculates / sets isFull void calcIsFull(); // Mutator setListHead(const node<nData> inListHead); // PRE: accepts const node pointer inListHead // POST: listHead is set to inListHead, maxCapacity, currCapacity recalculated // and listTail recalculated void setListHead(const node<nData> * inListHead); // Mutator setListTail(); // PRE: None // POST: Takes listHead, and traverses it to find the end, which is // what listTail takes. void setListTail(); // Mutator addAtHead(); // PRE: None // POST: Inserts a new empty node at the head // or if listHead is NULL, sets listHead to a new empty node void addAtHead(); // Mutator addAtHead(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode // POST: Inserts inNode into the linked list at the head, or if the // list is NULL, sets listHead to inNode void addAtHead(const node<nData> * inNode); // Mutator addAtHead(const node<nData> & inNode); // PRE: Accepts a const node reference inNode // POST: Inserts inNode into the linked list at the head, or if the // list is NULL, sets listHead to inNode void addAtHead(const node<nData> & inNode); // Mutator addAtHead(const nData * inData); // PRE: Accepts const nData pointer inData // POST: Adds a new node at the head of the linked list with inData // as the data member value, OR if listHead is NULL, sets // it to a new node with inData as its data member value void addAtHead(const nData * inData); // Mutator addAtHead(const nData & inData); // PRE: Accepts const nData referencd inData // POST: Adds a new node at the head of the linked list with inData // as the data member value, OR if listHead is NULL, sets // it to a new node with inData as its data member value void addAtHead(const nData & inData); // Mutator addAtTail(); // PRE: None // POST: Adds a new empty node after the tail pointer, sets the // tail pointer listTail to the newly created node void addAtTail(); // Mutator addAtTail(const node<nData> * inNode); // PRE: Accepts a const node pointer inNode // POST: Inserts inNode into the linked list at the tail, setting // the tail pointer to inNode void addAtTail(const node<nData> * inNode); // Mutator addAtTail(const node<nData> & inNode); // PRE: Accepts a const node reference inNode // POST: Inserts inNode into the linked list at the tail, setting // the tail pointer to inNode void addAtTail(const node<nData> & inNode); // Mutator addAtTail(const nData * inData); // PRE: Accepts const nData pointer inData // POST: Adds a new node at the tail of the linked list with inData // as the data member, and sets the tail pointer to inNode void addAtTail(const nData * inData); // Mutator addAtTail(const nData & inData); // PRE: Accepts const nData reference inData // POST: Adds a new node at the tail of the linked list with inData // as the data member, and sets the tail pointer to inNode void addAtTail(const nData & inData); // Mutator addAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity] // POST: Creates an empty node at inPos, linking it to nodes // that sequentially follow it in the list void addAtPos(const size_t inPos); // Mutator addAtPos(const node<nData> * inNode, const size_t inPos); // PRE: Accepts const node pointer inNode, accepts size_t inPos that // is not out of bounds [<= 0 or >= maxCapacity] // POST: Inserts inNode at inPos, linking it to nodes // that sequentially follow it in the list. void addAtPos(const node<nData> * inNode, const size_t inPos); // Mutator addAtPos(const node<nData> & inNode, const size_t inPos); // PRE: Accepts const node reference inNode, accepts size_t inPos that // is not out of bounds [<= 0 or >= maxCapacity] // POST: Inserts inNode at inPos, linking it to nodes // that sequentially follow it in the list. void addAtPos(const node<nData> & inNode, const size_t inPos); // Mutator addAtPos(const nData * inData, const size_t inPos); // PRE: Accepts const nData pointer inData, accepts size_t inPos that // is not out of bounds [<= 0 or >= maxCapacity] // POST: Inserts a new node at inPos, setting its data member value // to inData, and linking the node to nodes that sequentially // follow it in the list. void addAtPos(const nData * inData, const size_t inPos); // Mutator addAtPos(const nData & inData, const size_t inPos); // PRE: Accepts const nData reference inData, accepts size_t inPos that // is not out of bounds [<= 0 or >= maxCapacity] // POST: Inserts a new node at inPos, setting its data member value // to inData, and linking the node to nodes that sequentially // follow it in the list. void addAtPos(const nData & inData, const size_t inPos); // Mutator removeAtHead(); // PRE: None // POST: Removes node at the head, returns nothing. // Sets listHead to NULL if it was the last node // in the list void removeAtHead(); // Mutator removeAtHead() // PRE: None // POST: Removes node at the head, returns the node itself as // a pointer. Sets listHead to NULL if it was the last node // in the list node<nData> * removeAtHead(); // Mutator removeAtHead() // PRE: None // POST: Removes node at the head, returns the node itself as // a reference. Sets listHead to NULL if it was the last node // in the list node<nData> & removeAtHead(); // Mutator removeAtHead(); // PRE: None // POST: Removes node at the head, returns the data itself as // a nData pointer. Sets listHead to NULL if it was the last // node in the list nData * removeAtHead(); // Mutator removeAtHead(); // PRE: None // POST: Removes node at the head, returns the data itself as // a nData reference. Sets listHead to NULL if it was the last // node in the list nData & removeAtHead(); // Mutator removeAtTail() // PRE: None // POST: Removes node at the tail, nothing is returned, // making the node previous to it the tail // node if it exists, or if the tail pointer is the same as the // head pointer, sets it to NULL if it is the last node in // the list void removeAtTail(); // Mutator removeAtTail() // PRE: None // POST: Removes node at the tail, returns the node itself as // a pointer, making the node previous to it the tail // node if it exists, or if the tail pointer is the same as the // head pointer, sets it to NULL if it is the last node in // the list node<nData> * removeAtTail(); // Mutator removeAtTail() // PRE: None // POST: Removes node at the tail, returns the node itself as // a reference, making the node previous to it the tail // node if it exists, or if the tail pointer is the same as the // head pointer, sets it to NULL if it is the last node in // the list node<nData> & removeAtTail(); // Mutator removeAtTail(); // PRE: None // POST: Removes node at the tail, returns the data itself as // a nData pointer, making the node previous to it the tail // node if it exists, or if the tail pointer is the same as the // head pointer, sets it to NULL if it is the last node in // the list nData * removeAtTail(); // Mutator removeAtTail(); // PRE: None // POST: Removes node at the tail, returns the data itself as // a nData reference, making the node previous to it the tail // node if it exists, or if the tail pointer is the same as the // head pointer, sets it to NULL if it is the last node in // the list nData & removeAtTail(); // Mutator removeAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity] // POST: Removes the node at inPos; If it is the tail pointer, setting // the one before it as the tail pointer, or if it is the last // node in the list, listHead becomes NULL // Nothing is returned. void removeAtPos(const size_t inPos); // Mutator removeAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity] // POST: Removes the node at inPos; If it is the tail pointer, setting // the one before it as the tail pointer, or if it is the last // node in the list, listHead becomes NULL // The node is returned as a node pointer node<nData> * removeAtPos(const size_t inPos); // Mutator removeAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity] // POST: Removes the node at inPos; If it is the tail pointer, setting // the one before it as the tail pointer, or if it is the last // node in the list, listHead becomes NULL // The node is returned as a node reference node<nData> & removeAtPos(const size_t inPos); // Mutator removeAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity] // POST: Removes the node at inPos; If it is the tail pointer, setting // the one before it as the tail pointer, or if it is the last // node in the list, listHead becomes NULL // The data is returned as a nData pointer nData * removeAtPos(const size_t inPos); // Mutator removeAtPos(const size_t inPos); // PRE: Accepts const size_t inPos that is not out of bounds // [<= 0 or >= maxCapacity or >= currCapacity] // POST: Removes the node at inPos; If it is the tail pointer, setting // the one before it as the tail pointer, or if it is the last // node in the list, listHead becomes NULL // The data is returned as a nData reference nData & removeAtPos(const size_t inPos); }; } // End encapsulation into namespace tLinkedList // Include "node.template," which includes the function implementations for the // node class's member functions #include "linkedList.template" // End definition of LINKED_LIST__H #endif // End file linkedList.h
You're trying to overload on the return type alone, which isn't legal. That is, you cannot have two member functions that have the same names and the same parameter types, regardless of the return type.
I think the problem is that you are overloading functions with the same parameters but different return types, which is not possible in C++. There is a Stack Overflow entry about this. EDIT: TOO LATE! :v:
Alright, new conundrum: My node class works perfectly now. My linked list class is on its way to being that way, but I have some MAJOR issues. I have a head pointer, a tail pointer, a boolean value for when it is empty, a boolean value for when it is full, an integer value for the maximum capacity, and an integer for the current capacity. I right now implemented adding nodes - empty, or existing nodes - at the head of the list, which works perfectly. [haven't implemented anything else YET because of the current issues]. A function I have that traverses it to calculate the current capacity can do so with NO problems at all. When I try to set the tail pointer, or remove nodes at the head of the list, it causes the program using it to crash. NODE REMOVAL [AT HEAD] FUNCTION: Spoiler Code (Text): // Mutator removeAtHead(); // PRE: None // POST: Removes node at the head, returns nothing. // Sets listHead to NULL if it was the last node // in the list template <typename nData> void linkedList<nData>::removeAtHead() { // Check to see if we are trying to remove an empty node from the list. // Return if lHead is NULL, otherwise continue. if(lHead == NULL) { return; } else { // Create a temporary node node<nData> * removeNode; // Set that temporary node to lHead removeNode = lHead; // Set lHead to the next node it points to lHead = lHead->getNext(); // Free the memory allocated to removeNode - delete it delete removeNode; // Decrement currCapacity currCapacity--; // Calculate isEmpty calcIsEmpty(); } } [ASIDE from encapsulation into an if/els conditional, and the decrement of currCapacity/recalculation of isEmpty, it is copied out of the textbook I use. TAIL SETTING FUNCTION: Spoiler Code (Text): // Mutator setListTail(); // PRE: None // POST: Traverses the list recursively until it reaches // the end - or when the next node is NULL. // When this happens, the last node has been reached, and lTail // is set to cursor template <typename nData> void linkedList<nData>::setListTail() { // Create a temporary node, cursor, for traversing the list node<nData> * cursor; // Traverse the list until cursor is NULL for(cursor = lHead; cursor != NULL; cursor = cursor->getNext()) { // BUT if cursor's next link IS NULL, then we've found // the end - where our tail is if(cursor->getNext() == NULL) { // Set lTail to cursor lTail = cursor; } } // Free up memory used by cursor delete cursor; } I feel like a goddammed moron. EDIT: nevermind? It works perfectly compiled on mac OS X using NetBeans IDE and G++, but crashed using the MinGW compiler, Dev-C++ IDE? Now I really feel dumb.
You might still have a very subtle problem that for some reason only the gcc Dev-C++ is using is showing. Try running the program in the Dev-C++ debugger?