#include "list.h"
#include <iostream>
using namespace std;

/** DEFINITION OF CLASS NODE **/
class Node {
public:
  int data;
  Node *next;
  Node(int val, Node* p) {
    data = val;
    next = p;
  }
};

/** DEFINITION OF List's MEMBERS **/
void List::add2front(int val) {
  head = new Node(val,head);
}

bool List::contains(int val) {
  Node *p = head;
  while(p != 0 && p->data != val)
    p = p->next;
  return (p != 0);
}

List::~List() {
  while(head != 0)  {
    Node *p = head;
    head = head->next;
    delete p;
  }
}