I am trying to make a simple linked list. Everything was going fine, and then all of a sudden, a massacre of errors. I have no clue what I changed to break my code. This is my file that is getting some of the errors:
#pragma once
#include <string>
#include "Node.h"
class LinkedList
{
private:
Node *head;
public:
LinkedList();
~LinkedList();
void AddNode(int);
string GetList(); //missing ';' before identifier 'GetList'
bool Contains(int);
void Remove(int);
};
It claims that I am missing a semi-colon on the line above string GetList();
, or so it looks...but obviously I am not. That exact error is:
Error 1 error C2146: syntax error : missing ';' before identifier 'GetList' c:\...\linkedlist.h 15 1 ProjectName
The other error on that line is:
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\...\linkedlist.h 15 1 ProjectName
But it is identified as a string return type.
In LinkedList.cpp, this is the GetList() method:
string LinkedList::GetList(){
string list;
Node *currentNode = head;
while (currentNode->next_node){
currentNode = currentNode->next_node;
list += currentNode->get_value() + " ";
}
return list;
}
It all appears good there, but in the method header, I am getting the following 2 errors:
Error 4 error C2556: 'std::string LinkedList::GetList(void)' : overloaded function differs only by return type from 'int LinkedList::GetList(void)' c:\...\linkedlist.cpp 28 1 ProjectName
Error 5 error C2371: 'LinkedList::GetList' : redefinition; different basic types c:...\linkedlist.cpp 28 1 ProjectName
I have gone so far as to create a new project and copy and paste all of my files back in, but that had no effect. I had successfully run GetList() in this program previously.
Does anyone know what in the world is going on here? My IDE is lying to me! (Visual Studio Community 2013 Update 4)