Linked list and pointers :)

Ok So I'm studying linked list and pointers and having some fun with it. I have tried some different read and print methods using pointers. I can't get it to compile. I started to re write the program and compile it every time once I write a new method or function.
the problem is "pointer.cc:57:16: error: cannot convert ‘element* {aka int*}’ to ‘listnode*’ in assignment"

here is the code so far
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
#include <iostream>
#include <stdlib.h>
#include <limits>
#include <string>
using namespace std;
# undef NULL

typedef int element;
const int NULL=0;
const int SENTINEL=-1;
class listnode{
        public:
                element data;
                element * next;
        };

class LList{
        private:
                listnode * head;
                listnode * tail;

        public:
                LList();                //Constructor
                ~LList();               //Destructor
                void Read();
                void Readforward();
                void Readbackward();
                void Print();
                void Clean();

        };

int main(){
        LList L;
        L.Readforward();
        L.Print();
        }

LList::LList(){
	//PRE: None
	//POST: The N.O. is valid
	head=NULL;
	}
LList::~LList(){
	//PRE: The N.O. is valid
	//POST: The N.O. is valid and empty and all borrowed system resources
	// 	have been given back
	Clean();
	}
void LList::Clean(){
	//PRE: The N.O. LList is valid
	//POST: The N.O. is no empty, and all of it's previous listnodes 
	//	have been given to the system memory pool ("heap")
	listnode * temp;
	while(head != NULL){
		temp= head;
		head= head -> next;
		delete temp;
		}	
	}

To start with:

1
2
3
4
5
class listnode{
        public:
                element data;
                element * next; //shouldn't this be listnode*
        };
WOW, i feel retarted! thanks for the time
Topic archived. No new replies allowed.