Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python

C++


JAVA
PHP
SQL
Assignments

DLListExamples


stackAsAdllist.h

//--------------------------------------------------------------------
// stackAsAdllist.h
//
// Written by Chuck Cusack, Feb 2001
//--------------------------------------------------------------------
// Stack Class
// Implemented using a Doubly Linked list with Head and Tail pointers
//--------------------------------------------------------------------
#ifndef STACK2
#define STACK2
//--------------------------------------------------------------------
#include "dllist.h"
//--------------------------------------------------------------------
      // Make stack2 a derived class of dllist.  The keyword private
      // prevents the operations of dllist from being called.  This
      // makes sense, since I don't want the user to do operations like
      // InsertAtHead and InsertAtTail, since that would violate the
      // stack properties.
class stack2 : private dllist {  
                                 
public:
    stack2() {};  // Do nothing, except the base class constructor.
    ~stack2() {}; // Do nothing, except the base class destructor.
    // The copy constructor and assign operator will be the default.
    void Push(int K);
    int  Pop();
    int  Peek();
    void Purge();
    bool isEmpty () const;
};
#endif