Doubly Linked List Header File

I'm not sure why my destructor isn't working. I've tried different things but I'm out of ideas.

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
typedef struct Node;

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

class DoublyLinkedList_h
{
public: 
	const int DoublyLinkedList();
	const int DoublyLinkedList(char);
	~DoublyLinkedList();
	Node *head;
	int size;
	void addNodeBefore (char);
	void addNodeAfter (char);
	void addNodeBeforeData (char, Node*);
	void addNodeAfterData (char, Node*);
	void out(bool);
	void setData (char);
	void setNext (Node*);
	void setPrevious (Node*);
	void deleteData (char, bool);
	bool empty();
	bool findData(char);
};
That's hard to say without seeing the code for it.
I haven't written the code/implementation yet because the destructor gives me the error of "invalid destructor declaration" .
The name of the destructor must exactly match the name of the class (with the ~ in front of course).

Line 14, your class name is DoublyLinkedList_h (with _h), while on line 19 your destructor is DoublyLinkedList (no _h), so the compiler is trying to tell you they don't match,

Also, if line 17 and 18 are supposed to be constructors, constructors don't have a return type.


Makes perfect sense. Thank you !
Topic archived. No new replies allowed.