Linked List not working

#include <iostream>
#include <string>
#include <iomanip>
#include <list>
using namespace std;

//simple class to represent linked list nodes
template <class obj>

class Node {
public:
Node(Obj data): next(NULL) {
this -> data = data;
}

Node (): next(NULL){} //default constructor

Obj data;
Node<obj>*next;
};

//implement of a simple linked list
template <class Obj>
class List {
public:
//default constructor
List () {
this ->size = 0;
this -> head = NULL;
}

//add a node to the end of the list
void push_back (Obj data) {
if(this -> head == NULL) { //handle empty list
push_front(data);
return;
}

Node<Obj> *p = new Node<Obj> (data);
Node<Obj> *last = this -> head;

//go to the end of the list
while (last != NULL && last -> next != NULL) {
last = last -> next; //go to the next node
}

last -> next = p; //add the new node to the end
this -> size++; //increment the list count
}

//add a node at the beginning of the list
void push_front (Obj data) {
Node <Obj> *p = new Node <Obj> (data);

if (this -> head != NULL) { //if the list is not empty
p -> next = this -> head; //put the new node before the head
}
this -> head = p; //the new node is the head

this -> size++; //increment the list count
}

//get the first node
Obj front () {
if (this -> head != NULL)
return this -> head -> data;
}

//print all the elements starting with the head
void print() {
Node<Obj> *p = this -> head;
while (p != NULL) {
cout<<p-> data <<"\t";
p = p -> next;
}
}

private:
int size; //the number of nodes in the list
Node<Obj> *head; //link to the first node of the list
};

//driver stub
int main ()
{
List<int> l;
for (int i = 0; i < 5; i++)
l.push_front(1);
l.print();

cout<<"\Head node: "<<l.front()<<endl;
cout<<"Pop: "<<l.pop_front()<<endl;
l.print();
l.push_back(99);
l.print ();

system ("pause");
return 0;
}
1. Please use the code tags, to see some nice formatting
2. You have both Obj and obj
3. pop_front is not defined
4. Please explain what exactly is your problem
I received this code from my professor, and he wants me to define pop_front and create a destructor. I defined pop_front as so:

void pop_front (Obj data) {
if (this -> == NULL) {
pop_back (data);
return
}

But I'm not sure if it's right = / .

Also, what are the code tags?
But I'm not sure if it's right = / .

If it doesn't compile, you can be pretty sure it isn't right.

Also, what are the code tags?

http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.