#include class ListElem { public: int value; // Integer ListElem *next; // Pointer used to make link }; class List { public: ListElem *head; void InsertAtHead(ListElem * elem) { elem->next = this->head; this->head = elem; } void DeleteAtHead() { ListElem *p2; if (this->head == NULL ) return; p2 = this->head; this->head = p2->next; delete p2; } void Print() { ListElem *p; p = this->head; cout << "List ==> "; while ( p != NULL ) { cout << p->value << " "; p = p->next; } cout << "\n\n"; } }; int main(int argc, char *argv[]) { List myList; ListElem *p; p = new ListElem; p->value = 1500; myList.InsertAtHead(p); myList.Print(); p = new ListElem; p->value = 2500; myList.InsertAtHead(p); myList.Print(); p = new ListElem; p->value = 3500; myList.InsertAtHead(p); myList.Print(); myList.DeleteAtHead(); myList.Print(); }