This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

list.h

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 0.68 KB  |  views: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef LIST_H
  2. #define LIST_H
  3.  
  4. class List
  5. {
  6.     public:
  7.         List();
  8.         ~List();
  9.         void insert_at_end(int value);
  10.         void insert(int value); // insert at beginning of list
  11.         void print();
  12.         int sum();
  13.                 int m_value;
  14.          
  15.     private:
  16.         class Node
  17.         {
  18.             public:
  19.                 // small functions can be inserted into the class definition
  20.                 // don't put large functions in the class definition
  21.                 Node(int value, Node *next)
  22.                 {m_value = value; m_next = next;}
  23.                 int m_value;
  24.                 Node *m_next;
  25.                
  26.         };
  27.         Node *m_head;
  28. };
  29.  
  30. #endif
clone this paste RAW Paste Data