Linked list problem using g++

Hello everyone,

I am new to programming with cpp. I am having issues with a program when compiling in g++, but it works in VS. I would appreciate any insight from more experienced developers.

The code is as follows.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*----------------------------------------------------------------------
 -                     program2.cpp                                    -
 ----------------------------------------------------------------------*/

#include <iostream>
#include <string>
#include <fstream>

#include "linkedlist.h"

#define ignore cin.ignore();
using namespace std;
typedef std::string KeyType;

void menu();
void loader();

int main(int argc, char *argv[])
{
	char choice;      
	bool menuFlag;  
	//string key;
	//string name;
	//string title;
	LinkedList l;
	KeyType findKey;
	KeyType addKey;
	KeyType rmKey;
	Articles s;  
	Articles temp; 
	
	cout << "Loading library please wait.";
	fflush(stdout); 
	sleep(1); 
	cout << "."; 
	fflush(stdout); 
	sleep(1); 
	cout << "."; 
	sleep(1);
	puts("."); 
	cout << endl;
	
	fstream inFile(argv[1]);	
		if (inFile.is_open()) 
	{
		while (!inFile.eof()) 
		{
			getline (inFile,s.key);   
			getline (inFile,s.name);  
			getline (inFile,s.title); 
			if (s.key >= " ")        
				l.insert(s);         
		}
		inFile.close();     
	}
	else  
	{
		cout << "Unable to open file";  
	}
	loader();
	
	cout << "Hello to the CACM Library!" << endl;
	menu();  
	
	menuFlag = true; 
	while (menuFlag) 
	{  
		cout << "\nYour Choice:"; 
		cin  >> choice;           
		cout << endl;
		
		if (choice == 'f' || choice == 'F') 
			{
			cout << "You have chosen to search for an article" << endl; //-----!!Remove when complete!!-----//
			cout << "\nPlease enter your search key: ";
			getline(cin, findKey);
			if (l.find(findKey,temp))         
				{
					cout << endl;                 //no error.
					menu();
				}
				else if (!l.find(findKey,temp))   //key not found
				{
					cout << "---------------------------------------------------------" << endl;
					cout << "-  Sorry, but there are no records matching your query. -" << endl;
					cout << "---------------------------------------------------------" << endl << endl;
					menu();
				}
			
			cout << "\n" << endl;
			menu();
			}
	
		else if (choice == 'l' || choice == 'L') 
			{
				l.display();          
				cout << endl;
				menu();
				
				cout << "\n" << endl;
				menu();
			}
		else if (choice == 'a' || choice == 'A') 
			{
			ignore;
				cout << "Enter the key for your new article:"; 
				getline(cin, addKey);                  
				if (l.find(addKey,s))                
				{
					cout << "Article key already exists! Choose another key." << endl; 
					menu();
				}
				else if (!l.find(addKey,s))          
				{
					s.key = addKey;                  
					cout << endl << "Enter the author's name:"; 
					cin >> s.name;                       
					cout << endl << "Enter the title of the article:";  
					cin >> s.title;                       
					l.insert(s);                          
						cout << endl;                    
						cout << "------------------------------------------" << endl;
						cout << "- The following record has been ADDED    -" << endl;
						cout << "-                                        -" << endl;
						cout << "-    Key: " << s.key << "				  -" << endl;
						cout << "-  Title: " << s.title << "			  -" << endl;
						cout << "- Author: " << s.name << "				  -" << endl;
						cout << "-----------------------------------------*" << endl;
						menu();
				}
				cout << endl;
				
			cout << "\n" << endl;				
			menu();
			}
		else if (choice == 'r' || choice == 'R') 
			{
			
				cout << "You have chosen to remove an article" << endl; //-----!!Remove when complete!!-----//
				cout << "\nEnter the key for the article that you want to remove: ";
				getline(cin, rmKey);
                 
				if (!l.erase(rmKey))             
				{
					cout << "----------------------------------------------------------------------" << endl;
					cout << "- Sorry, record not removed because it was not found in the database -" << endl;
					cout << "----------------------------------------------------------------------" << endl;
					menu();
				}
				else                                
				{
					l.erase(rmKey);            
					cout << "-----------------------------------------------------" << endl;
					cout << "- The following record has been REMOVED             -" << endl;
					cout << "-                                                   -" << endl;
					cout << "- Key: " << rmKey << "                              -" << endl;
					cout << "-----------------------------------------------------" << endl;
					menu();
				}
				cout << endl;
				
				menu();
			}			
		else if (choice == 'e' || choice == 'E')  
		{
			cout << "Thank you for using the CACM Library!" << endl;  
			menuFlag=false; 
		}
		else 
		{
			cout << "Invalid Choice." << endl; 
			menu();
		}
	}
	return 0;
}


void loader() 
{
return;
}

void menu()  
{
	cout << "\nWhat would you like to do?" << endl;
	
	cout << "\n(F)ind an article" << endl
		 << "(L)ist all articles" << endl
		 << "(A)dd a new article" << endl
		 << "(R)emove an existing article" << endl
		 << "(E)xit" << endl;
	
}


Next:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*----------------------------------------------------------------------
 -               linkedlist.h                                          -
 ----------------------------------------------------------------------*/
#include <iostream>
#include <string>
using namespace std;

typedef struct Articles ElementType;
typedef std::string KeyType;

//struct which has three elements: key, name, and title
struct Articles
{
	string key;
	string name;
	string title;
};

class LinkedList
{
	private:
		class Node
		{
		public:
			ElementType data;
			Node * next;
			Node(ElementType item){		
				data = item;
				next = NULL;
			}
		};
		typedef Node * NodePointer;
		Node *LinkedList::found(const KeyType &key)
		{
			NodePointer ptr;
			ptr = first;
			ElementType item;
			while (ptr != NULL)
			{
				if (ptr->data.key == key)
				{
					item.key = ptr->data.key;
					item.title = ptr->data.title;
					item.name = ptr->data.name;
					cout << "-----------------------------------------------------------------------------------" << endl;
					cout << "     Key: " << item.key << endl;
					cout << "   Title: " << item.title << endl;
					cout << "  Author: " << item.name << endl;
					cout << "-----------------------------------------------------------------------------------" << endl;
					return ptr;
				}
				else
					ptr = ptr->next;
			}
			if (ptr == NULL)
				return NULL;
		}
		Node *LinkedList::deleter(const KeyType &key)
		{
			NodePointer ptr;
			ptr = first;
			ElementType item;
			while (ptr != NULL)
			{
				if (ptr->data.key == key)
				{
					predPtr->next=ptr->next;
					delete ptr;
					return predPtr;
				}
				else
					ptr = ptr->next;
			}
			if (ptr == NULL)
				return NULL;
		}
		NodePointer first;
		NodePointer predPtr;
	public:
		LinkedList();
		void insert (const ElementType &item);
		bool find (const KeyType &key, ElementType &item);
		bool erase (const KeyType &key);
		void display();
};
		bool operator<(const ElementType &e1, const KeyType &key);
		bool operator>=(const ElementType &e1, const KeyType &key);


The error I am receiving from g++ is as follows:
In file included from program2.cpp:11:
LinkedList.h:35: error: extra qualification 'LinkedList::' on member 'found'
LinkedList.h:60: error: extra qualification 'LinkedList::' on member 'deleter'


I understand that the code is a bit screwy and that the Node class should not be in the LinkedList class. However, I am at my wits end trying to fix it. Any insight on how I can fix the issues would be amazing.

Regards,
Jason
Here is the code for the linkedlist.cpp file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*----------------------------------------------------------------------
 -                     linkedlist.cpp                                  -
 ----------------------------------------------------------------------*/
#include <iostream>
#include <iomanip>
using namespace std;
#include "linkedlist.h"

//contructor
void LinkedList::LinkedList()
{
	first = NULL;
}

//insert method 
void LinkedList::insert(const ElementType &item)
{
	NodePointer nPtr = new Node(item);
	predPtr = first;
	NodePointer afterPtr;
	if (first == NULL)
	{
		nPtr->next = first;
		first = nPtr;
	}
	else if (predPtr->data >= nPtr->data.key)
	{
		nPtr->next = first;
		first = nPtr;
	}
	else
	{
		while (!((predPtr->next == NULL) || (predPtr->next->data >= nPtr->data.key)))
		{
			predPtr=predPtr->next;
		}
		nPtr->next = predPtr->next;
		predPtr->next = nPtr;
	}
}

//find method
bool LinkedList::find(const KeyType &key, ElementType &item)
{
	if (found(key))
	{
		return true;
	}
	else if (!found(key))
		return false;
}

//erase method
bool LinkedList::erase(const KeyType &key)
{
	if (deleter(key))
	{
		return true;
	}
	else if (!deleter(key))
		return false;
}

//display method
void LinkedList::display()
{
	LinkedList::NodePointer ptr;
	ptr = first;
	cout << "--------------------------------------------------------------------------------" << endl;
	cout << " Key                 Author                Title                          " << endl;
	cout << "--------------------------------------------------------------------------------" << endl;
	while (ptr != NULL)
	{
		cout << left << setw(20) << ptr->data.key << " " << setw(20) << ptr->data.name << "  " << setw(40) << ptr->data.title << endl;
		ptr = ptr->next;
	}
}

//overloading ==
bool operator==(const ElementType &e1, const KeyType &key)
{
	if (e1.key == key)
		return true;
	else
		return false;
}

//overloading >=
bool operator>=(const ElementType &e1, const KeyType &key)
{
	if (e1.key >= key)
		return true;
	else
		return false;
}


Please offer any insight.
Do exactly what the error message says. Remove LinkedList:: from the declaration/implementation
of deleter and found.
Topic archived. No new replies allowed.