Struggling With My Linked List

I'm trying to print the objects in the provided list to the user, and then give them the option of adding on a node or not. If they want to, they're able to pick the location for it as well. But when it comes to code, I'm receiving an error on line 43 of the test code stating that my declaration is incompatible with my line 38 in my header file. I've changed "beginning" to int, string, and as the current type - char. Same error goes for line 60 in the test code.

HEADER 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
#ifndef DoublyLinkedList_h
#define DoublyLinkedList_h

//typedef struct Node;

struct Node
{
	int data;
	Node *next,*previous;
	Node (int a, Node *pre, Node *next) : data(a), previous(pre), next(next)
	{
		if(pre) previous -> next = this;
		if (next) next -> previous = this;
	}
};

/*
The purpose of this class is to provide a linked list and give the option for the user to add 
a node to the beginning or the end of the list. It also allows the user to delete a node if 
needed to.
*/

class DoublyLinkedList
{
public: 
	DoublyLinkedList(int);
	DoublyLinkedList();
	~DoublyLinkedList();
	Node *head;
	int size;
	char beginning;
	char end;
	void addNodeBefore (int);
	void addNodeAfter (int);
	void addNodeBeforeData (int, Node*);
	void addNodeAfterData (int, Node*);
	//void out(bool);
	void setData (int);
	void setNext (Node*);
	void setPrevious (Node*);
	void deleteData (int, bool);
	bool empty();
	bool findData(int);
};
#endif  


IMPLEMENTATION OF HEADER 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
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
#include <iostream>
#include <string>
#include <iomanip> 
#include "DoublyLinkedList.h"
using namespace std;

DoublyLinkedList::DoublyLinkedList (int data)
{
	head = new Node (data, NULL, NULL);
	head ->next = head ->previous = head;
	size = 3;
	//int list [16];
}

DoublyLinkedList::DoublyLinkedList()
{
	Node *temp = this->head;
	Node *temp2;
	while (temp->previous)
		temp = temp ->previous;
	while(temp)
	{
		temp2 = temp ->next;
		delete temp;
		temp = temp2;
	}
	temp = temp2 = NULL;
}

bool DoublyLinkedList::empty()
{
	return (this ->size == 0);
}

void DoublyLinkedList ::addNodeBefore (int data)
{
	Node *next = head;
	Node *previous = head ->previous;

	Node *temp2 = new Node (data, previous, next);
	size++;
}

void DoublyLinkedList::addNodeAfter(int data)
{
	Node *next = head ->next;
	Node *previous = head;

	Node *temp2 = new Node (data, previous, next);
	size++;
}

/*void DoublyLinkedList::out(bool directly)
{
	if (directly)
	{
		Node *temp = head;
		do 
		{
			cout<<temp ->data;
			temp = temp->next;
		}
		while (temp != head);
	}
	else
	{
		Node *temp = head;
		do
		{
			cout<<temp->data;
			temp = temp ->previous;
		}
		while (temp != head);
	}
	cout<<endl;
}*/

void DoublyLinkedList::setData( int Data)
{
	this ->head->data = Data;
}
void DoublyLinkedList::setPrevious(Node* Previous)
{
	this ->head->previous = Previous;
}
void DoublyLinkedList::setNext( Node* Next)
{
	this ->head->next = Next;
}

bool DoublyLinkedList::findData (int find)
{
	int counterStart = 0;
	Node *temp = head;
	while (temp ->next != head)
	{
		if (temp ->data == find)
			counterStart++;
		temp = temp->next;
	}

	if (counterStart > 0)
	{
		cout<<" ' "<<find<<" ' was found"<<counterStart<<" time(s)"<<endl;
		return true;
	}
	else
	{
		cout<<" ' "<<find<<" ' was not found"<<endl;
		return false;
	}
}

void DoublyLinkedList::deleteData(int find, bool everything)
{
	Node *temp = head;
	while (temp)
	{
		if (temp ->data == find)
		{
			cout<<"Removing "<<find<<endl;
			temp ->previous->next = temp ->next;
			temp ->next->previous = temp ->previous;
			if (false)
				return;
		}
		temp = temp ->next;
	}
}


TESTING 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
#include <iostream>
#include <string>
#include <iomanip> 
#include "DoublyLinkedList.h"

using namespace std;

int main ()
{
	int providedNumbers [] = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31};

	DoublyLinkedList *list;
	Node *current;

	list = new DoublyLinkedList (providedNumbers[0]);

	for (size_t i = 1; i < sizeof (providedNumbers)/sizeof (*providedNumbers); i++)
		list -> addNodeAfter (providedNumbers[i]);

	cout<<"The contents of the provided list are "<<providedNumbers<<endl;
	bool answer;
	cout<<"Would you like to add onto this list, true or false?"<<endl;
	cin>>answer;

	if (answer == false)
	{
		cout<<"Ok, thank you"<<endl;
	}

	if (answer == true)
	{
		cout<<"Where would you like to add your new node?"<<endl;
		string location;
		cin>>location;
		string beginning;

		if (location == beginning)
		{ 
			cout<<"What is your added value?"<<endl;
			int numberTaken;
			cin>>numberTaken;

void DoublyLinkedList ::beginning(int numberTaken)
{
	Node *next = head;
	Node *previous = head ->previous;

	Node *temp2 = new Node (data, previous, next);
	size++;
}
		}

		string end;
	if (location == end)
	{ 
		cout<<"What is your added value?"<<endl;
		int numberTaken;
		cin>>numberTaken;

void DoublyLinkedList::end(int numberTaken)
{
	Node *next = head ->next;
	Node *previous = head;

	Node *temp2 = new Node (data, previous, next);
	size++;
}
	}


system ("pause");
	return 0;
}
Topic archived. No new replies allowed.