I get these two errors when I compile
The part of the file that it's telling me about are these two functions -Code:/home/sterling/CODE/UnorderedList/UnorderedList.cpp|22|error: expected constructor, destructor, or type conversion before ‘&’ token| /home/sterling/CODE/UnorderedList/UnorderedList.cpp|23|error: expected constructor, destructor, or type conversion before ‘&’ token|
I feel like it's telling me that it doesn't recognize Node, but I don't understand why. Node is a nested class in UnorderedList.h. That file is this -Code://GETTER FUNCTIONS Node& UnorderedList::Node::getNext() {return next;} Node& UnorderedList::Node::getPrevious() {return previous;}
I don't see why the exception classes compile fine but Node doesn't. I have tried changing the return from Node& to Node*, changing the return in .cpp to UnorderedList::Node&, and other random things. None have worked though. Can anyone tell me what's wrong? Thanks.Code:#ifndef UNORDEREDLIST_H #define UNORDEREDLIST_H #include <exception> class UnorderedList { public: class EmptyListException: public std::exception { public: virtual const char* what() const throw(); }; //END EMPTYLISTEXCEPTION class InvalidInputException: public std::exception { public: virtual const char* what() const throw(); }; //END INVALIDINPUTEXCEPTION class Node { public: Node(int element); ~Node(); Node& getNext(); Node& getPrevious(); int& getElement(); private: int element; Node* next; Node* previous; }; //END NODE CLASS UnorderedList(); ~UnorderedList(); void add(int element); int remove(int element); void print(); int size(); bool isEmpty(); private: Node* head; int count; }; #endif



LinkBack URL
About LinkBacks


