Somewhat generic stack code. Data is an int for simplicity. It should work, but I make no guarantees!!

     stack.h - header file for a stack data structure.

#ifndef STACK_H
#define STACK_H

#include <stdlib.h>
#include <iostream.h>

class node;
class stack;

class node
    friend stack;
        int data;
        node *link;

class stack
        int peek();
        int pop();
        void push( int loc );
        bool isEmpty();
        int size();
        node * first;
        bool empty;
        int howBig;

#endif                          //STACK_H

  source code for a stack data structure, implemented using a linked list

#include "stack.h"

    first = new node;
    first->link = 0;
    //empty = true;
    howBig = 0;

    node * next;

    while ( first != 0 ) {
        next = first->link;
        delete first;
        first = next;

int stack::peek()
    return first->data;

int stack::pop()
    if ( ! isEmpty() ) {
        int x = first->data;
        node *temp = first;
        first = first->link;
        delete temp;
        return x;
    } else {
        cerr << "Stack is empty.\n";
        exit( 1 );
        return 0;   //  MSVC insists that all control paths must 
                    //  return a value. Duhhh...

bool stack::isEmpty()
    return ( first == 0 );

void stack::push( int loc )
    empty = false;
    node *temp = new node;
    temp->data = loc;
    temp->link = first;
    first = temp;

int stack::size()
    return howBig;

STACKS is also an MS-DOS command. It establishes and sets aside the number and length of some RAM memory operations. The default is 9 memory stacks at 256 bytes.

The physical collection a library owns, put in handy shelf-oriented storage for your convenience. The stacks smell musty or bright or varnishy, thick and silent. The stacks are dim and quiet and cool, floored with cement or industrial carpet, flanked by desks and chairs and long tables. Paper muffles sound, and you see paper on all sides. You are surrounded by books. Here are the Canadian tax records 1974-75 1975-76 1976-77. Here is the new Malaysian economic plan. Here are the children's novels, here are the histories of individual Ohio counties, here are the huge bound biology journals that no one ever opens.

The stacks are a good place to hide. You look up your books and end up searching them out in a remote corner of the basement, on floor 3a behind the scary little elevator no one voluntarily uses unless they have carts of books to shelve. You are hidden without ever having that specific intention. You end up on the floor, rifling through a certain second shelf.

Literally, the stacks are the place of storage for a given library's bound paper collection(s). This does not include unbound items such as new periodicals: these usually have their own separate section, shiny, at the front of the library. They are easy to find; they are not a maze. Later, however, as the issues get older and older, they will be sent off to the bindery, come back stacked in shiny new buckram. They will be moved to the stacks, down heavy corridors of shelves to their own particular space within the archive. The stacks become storage for books left unused for years at a time, as well as those used often. Dust will settle over whole shelves, while others are spit-clean. The deeper you delve, the older, less used, and more fragile they get. Corners crumble into your accidental elbow, mites and mold creep into bindings.

Larger libraries will have more stacks, as they have more holdings. Older libraries will have dustier stacks. Smaller libraries, like the one in the center of your junior high school building, will barely have anything that could be called a single stack. Stacks are, by definition, large; they are bulky. The stacks are an archive, and with that comes archival problems. One may get lost in them, or at least not be able to find the right book. They develop mildew. They groan under their own weight, entirely full, and then where do you put the new books always on order, always coming in?

The stacks are the heart of your archive. They hold everything together; everything is hidden in the stacks, anything that has ever come through your library. Books are misshelved, reshelved, found, marked "missing" with a red flag in the holdings database.

People live here. They leave caches of books in study carrels, hoping they will still be there later. They study frantically, leave frustrated graffiti and gum wrappers behind. They exchange frantic kisses, backed up against the closest shelf. They crouch over their research in corners. They smoke worriedly in the back stairwell, right under the NO SMOKING placard. They eat their illegal lunch. They spill coffee in the worst possible places.

The stacks will hold you and keep you; they hide you, they help you, they give you their knowledge. They are a haven from a noisy dorm, a trove of free books for a poor student. There is always an appropriate corner: a place to read, to work, to think, to escape when you most need it.

Log in or register to write something here or to contact authors.