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 {
Node(Obj data): next(NULL) {
this -> data = data;

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

Obj data;

//implement of a simple linked list
template <class Obj>
class List {
//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

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;

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++)

cout<<"\Head node: "<<l.front()<<endl;
cout<<"Pop: "<<l.pop_front()<<endl;
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);

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?
Topic archived. No new replies allowed.