User Tools

Site Tools


user:nbrimme1:portfolio:eoce

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user:nbrimme1:portfolio:eoce [2013/12/14 05:16] nbrimme1user:nbrimme1:portfolio:eoce [2013/12/14 20:11] (current) nbrimme1
Line 1: Line 1:
 +__**This is the C++ code I had finished for the End of Course Experience C++ Re-implementation:**__
 +\\
 +(The code provided by Matt is also included.)
 +\\
 +//Files are located in **src/data/EoCE/ll_oop_reimp**//
 +\\
 +**Makefile:**
 +<code make>
 +SHELL = /bin/bash -e
 +INC = -I inc/
 +CXXFLAGS = -Wall 
 +OPTS =
 +CXX = g++ $(CXXFLAGS) $(OPTS) $(INC)
 +OBJ = 
 +AR = ar
 +DEBUG = 
 +LIBS = src
 +UNIT = testing
 +ALL = $(LIBS) testing
 +BIN = 
 +default: libs testing
 +debug: libs-debug testing-debug
  
 +libs-debug: CXX += -DDEBUG -g
 +libs-debug: DEBUG = debug
 +libs-debug: libs
 +
 +libs:
 + @for i in $(LIBS); do make -C $$i $(DEBUG); echo; done
 + @echo
 +
 +testing-debug: CXX += -DDEBUG -g
 +testing-debug: DEBUG = debug
 +testing-debug: testing
 +
 +testing:
 + @for i in $(UNIT); do make -C $$i $(DEBUG); echo; done
 + @echo
 +
 +clean:
 + @for i in $(ALL); do make -C $$i clean; done
 + @rm -f lib/*
 +
 +copy:
 + mkdir -p ~/src/data/EoCE/ll_oop_reimp
 + cp -av /var/public/data/fall2013/EoCE/ll_oop_reimp/* ~/src/data/EoCE/ll_oop_reimp/
 +
 +help:
 + @echo
 + @echo "*************[ Data Structures OOP List Re-Implementation ]*************"
 + @echo "** make                     - build everything                        **"
 + @echo "** make debug               - build everything with debug symbols     **"
 + @echo "**                                                                    **"
 + @echo "** make testing             - build unit tests                        **"
 + @echo "** make testing-debug       - build unit tests with debugging symbols **"
 + @echo "** make libs                - build all supporting libraries          **"
 + @echo "** make libs-debug          - build all libraries with debug symbols  **"
 + @echo "**                                                                    **"
 + @echo "** make clean               - clean; remove all objects/compiled code **"
 + @echo "** make help                - this information                        **"
 + @echo "************************************************************************"</code>
 +\\
 +**/inc:**
 +  * **list.h:**<code c>
 +#ifndef _LIST_H
 +#define _LIST_H
 +
 +#include "node.h"
 +
 +class List {
 + public:
 + List();
 + void insert(Node *, Node *);
 + void append(Node *, Node *);
 + Node *getNode(Node *);
 + void displayf();
 + void displayb();
 + void sort();
 + int  getQuantity();
 + Node * getStart();
 + Node * getEnd();
 + ~List();
 +
 + private:
 + Node *start;
 + Node *end;
 + int qty;
 +};
 +
 +#endif</code>
 +
 +  * **node.h:**<code c>
 +#ifndef _NODE_H
 +#define _NODE_H
 +
 +#include <cstdlib>
 +
 +class Node {
 + public:
 + Node();
 + Node(int);
 + Node *copy();
 + int   getValue();
 + Node *getNext();
 + Node *getPrev();
 + Node *getData();
 + void  setNext(Node *);
 + void  setPrev(Node *);
 + void  setData(Node *);
 + void  setValue(int);
 + ~Node();
 +
 + private:
 + Node *next;
 + Node *prev;
 + Node *data;
 + int value;
 +};
 +
 +#endif</code>
 +
 +  * **queue.h**<code c>
 +#ifndef _QUEUE_H
 +#define _QUEUE_H
 +
 +#include "list.h"
 +
 +class Queue : protected List {
 + public:
 + Queue();
 + Queue(int);
 + void  enqueue(Node *);
 + Node *dequeue();
 + int   getBufferSize();
 + void  setBufferSize(int);
 + ~Queue();
 +
 + private:
 + List *data;
 + Node *front;
 + Node *back;
 + int bufsiz;
 +};
 +
 +#endif</code>
 +
 +  * **stack.h**<code c>
 +#ifndef _STACK_H
 +#define _STACK_H
 +
 +#include "list.h"
 +
 +class Stack : protected List {
 + public:
 + Stack();
 + Stack(int);
 + void  push(Node *);
 + Node *pop ();
 + Node *peek();
 + int   getSize();
 + int   getListSize();
 + void  setSize(int);
 + ~Stack();
 +
 + private:
 + List *data;
 + Node *top;
 + int size;
 +};
 +
 +#endif</code>
 +\\
 +**/lib:** Files in this directory are made using the make file:
 +<cli>lab46:~/src/data/EoCE/ll_oop_reimp$ make</cli>
 +\\
 +**/src:**
 +  * **Makefile:**<code c>
 +SHELL = /bin/bash -e
 +INC = -I ../inc/
 +CFLAGS = -Wall 
 +OPTS =
 +CXX = g++ $(CFLAGS) $(OPTS) $(INC)
 +PARTS = $(shell /bin/ls -1Ad * | grep -v 'Makefile')
 +DEBUG = 
 +default: libs
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: libs
 +
 +libs:
 + @for i in $(PARTS); do make -C $$i $(DEBUG); echo; done
 + @echo
 +
 +clean:
 + @for i in $(PARTS); do make -C $$i clean; done
 + @rm -f ${LIB}</code>
 +  * **/btree**
 +    * **Makefile:**<code>
 +CFLAGS = -Wall
 +INC = -I ../../inc
 +AR = ar
 +CXX = g++ $(CFLAGS) $(INC) 
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +OBJ = $(SRC:.cc=.o)
 +LIB = $(shell /bin/pwd | /bin/sed 's/^.*\///')
 +all: $(SRC) $(OBJ) lib
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(OBJ) lib
 +
 +.cc.o:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -c $< && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -c $<
 +endif
 +
 +lib:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[L]   %-20s ... " "$<"
 + @$(AR) rcs ../../lib/lib$(LIB).a $(OBJ) && echo "SUCCESS" || echo "FAIL"
 +else
 + $(AR) rcs ../../lib/lib$(LIB).a $(OBJ)
 +endif
 +
 +
 +clean:
 + rm -f *.o $(OBJ) core</code>
 +\\
 +  * **/list**
 +    * **Makefile:**<code c>
 +CFLAGS = -Wall
 +INC = -I ../../inc
 +AR = ar
 +CXX = g++ $(CFLAGS) $(INC) 
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +OBJ = $(SRC:.cc=.o)
 +LIB = $(shell /bin/pwd | /bin/sed 's/^.*\///')
 +all: $(SRC) $(OBJ) lib
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(OBJ) lib
 +
 +.cc.o:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -c $< && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -c $<
 +endif
 +
 +lib:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[L]   %-20s ... " "$<"
 + @$(AR) rcs ../../lib/lib$(LIB).a $(OBJ) && echo "SUCCESS" || echo "FAIL"
 +else
 + $(AR) rcs ../../lib/lib$(LIB).a $(OBJ)
 +endif
 +
 +
 +clean:
 + rm -f *.o $(OBJ) core</code>
 +    * **append.cc:**<code c>
 +#include "list.h"
 +
 +void List :: append(Node *place, Node *newNode)
 +{
 +// append() - insert newNode after place.
 +
 +void List :: append(Node *place, Node *newNode)
 +{
 + Node *tmp;
 + if ((this != NULL) && (newNode != NULL))
 + {
 + if (this -> end == NULL)
 + {
 + this    -> end = this  -> end  = newNode;
 + newNode -> setPrev(NULL);
 + newNode -> setNext(NULL);
 + }
 + else if (place == this -> end)
 + {
 + this    -> end -> setPrev(newNode);
 + newNode -> setNext(this -> end);
 + this    -> end = newNode;
 + }
 + else
 + {
 + newNode -> setNext(place);
 + if (place != NULL)
 + {
 + newNode -> setPrev(place -> getPrev());
 + place   -> setPrev(newNode);
 + tmp = newNode -> getPrev();
 + tmp -> setNext(newNode);
 + }
 + }
 + // Update quantity variable.
 + this -> qty = this -> qty + 1;
 + }
 +}</code>
 +    * **create.cc:**<code c>
 +#include "list.h"
 +
 +List :: List()
 +{
 + this -> start = NULL;
 + this -> end   = NULL;
 + this -> qty   = 0;
 +}</code>
 +    * **destroy.cc:**<code c>
 +#include "list.h"
 +
 +List :: ~List()
 +{
 + Node *node, *nextNode;
 + node = this -> start;
 + while (node != NULL)
 + {
 + // Set the next node pointer before node is removed.
 + nextNode = node -> next;
 + // Delete the Node.
 + delete node;
 + // Iterate to the next node.
 + node = nextNode;
 + }
 +}</code>
 +    * **display.cc:**<code c>
 +#include "list.h"
 +#include <stdio.h>
 +
 +void List :: displayf()
 +{
 + Node *tmp;
 + int i = 0;
 +
 + tmp = this -> start;
 +
 + while (tmp != NULL)
 + {
 + fprintf(stdout, "[%u] %u -> ", i, tmp -> getValue());
 + i = i + 1;
 + tmp = tmp -> getNext();
 + }
 +
 + fprintf(stdout, "NULL\n");
 +}
 +
 +void List :: displayb()
 +{
 + Node *tmp;
 + int i = getQuantity();
 +
 + tmp = this -> end;
 +
 + while (tmp != i)
 + {
 + fprintf(stdout, "[%u] %u -> ", i, tmp -> getValue());
 + i = i - 1;
 + tmp = tmp -> getPrev();
 + }
 +
 + fprintf(stdout, "NULL\n");
 +}</code>
 +    * **end.cc:**<code c>
 +#include "list.h"
 +
 +Node * List :: getEnd()
 +{
 + // Return the end of the list.
 + return (this -> end;)
 +}</code>
 +    * **getnode.cc:**<code c>
 +#include "list.h"
 +
 +Node * List :: getNode (Node *place)
 +{
 + // to be implemented
 + // get input.
 + // iterate through list to input + 1 (Because 0 is counted).
 + // return input + 1.
 +}</code>
 +    * **insert.cc:**<code c>
 +#include "list.h"
 +
 +// insert() - insert newNode before place in this
 +
 +void List :: insert(Node *place, Node *newNode)
 +{
 + Node *tmp;
 + if ((this != NULL) && (newNode != NULL))
 + {
 + if (this -> start == NULL)
 + {
 + this    -> start = this  -> end  = newNode;
 + newNode -> setPrev(NULL);
 + newNode -> setNext(NULL);
 + }
 + else if (place == this -> start)
 + {
 + this    -> start -> setPrev(newNode);
 + newNode -> setNext(this -> start);
 + this    -> start = newNode;
 + }
 + else
 + {
 + newNode -> setNext(place);
 + if (place != NULL)
 + {
 + newNode -> setPrev(place -> getPrev());
 + place   -> setPrev(newNode);
 + tmp = newNode -> getPrev();
 + tmp -> setNext(newNode);
 + }
 + }
 + // Update quantity variable.
 + this -> qty = this -> qty + 1;
 + }
 +}</code>
 +    * **size.cc:**<code c>
 +#include "list.h"
 +
 +int List :: getQuantity()
 +{
 + return(qty);
 +}</code>
 +    * **sort.cc:**<code c>
 +#include "list.h"
 +
 +void List :: sort()
 +{
 +  list = this;
 +  list :: iterator = i;
 +
 +  list.sort();
 +  std::cout << "Sorted List: ";
 +  // Iterate through the list
 +  for (i = this.begin(); i != this.end(); ++i)
 +
 +  // Compare the values
 +  // If this->node->value > this->node->next->value
 +  // remove this->node; append after this->node->next
 +
 +  // Print sorted values.
 +    std::cout << ' ' << *i;
 +
 +return (0);
 +}</code>
 +    * **start.cc:**<code c>
 +#include "list.h"
 +
 +Node * List :: getStart()
 +{
 + // Return the start of the list.
 + return (this -> start;)
 +}</code>
 +\\
 +  * **/node**
 +    * Makefile:<code c>
 +CFLAGS = -Wall
 +INC = -I ../../inc
 +AR = ar
 +CXX = g++ $(CFLAGS) $(INC) 
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +OBJ = $(SRC:.cc=.o)
 +LIB = $(shell /bin/pwd | /bin/sed 's/^.*\///')
 +all: $(SRC) $(OBJ) lib
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(OBJ) lib
 +
 +.cc.o:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -c $< && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -c $<
 +endif
 +
 +lib:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[L]   %-20s ... " "$<"
 + @$(AR) rcs ../../lib/lib$(LIB).a $(OBJ) && echo "SUCCESS" || echo "FAIL"
 +else
 + $(AR) rcs ../../lib/lib$(LIB).a $(OBJ)
 +endif
 +
 +
 +clean:
 + rm -f *.o $(OBJ) core</code>
 +    * copy.cc:<code c>
 +#include "node.h"
 +
 +Node * Node :: copy()
 +{
 + // First create an empthy node.
 + Node *tmp;
 + Node *tmp2 = new Node;
 +
 + // "Get" then "Set" the next pointer for tmp2.
 + tmp = this -> getNext();
 + tmp2 -> setNext(tmp)
 +
 + // "Get" then "Set" the prev pointer for tmp2.
 + tmp = this -> getPrev();
 + tmp2 -> setPrev(tmp);
 +
 + // "Get" then "Set" the value pointer for tmp2.
 + tmp = this -> getValue();
 + tmp2 -> setValue(tmp);
 +
 + // "Get" then "Set" the data pointer for tmp2.
 + tmp = this -> getData();
 + tmp2 -> setData(tmp);
 +
 + // Return copied node.
 + return(tmp2);
 +}</code>
 +    * create.cc:<code c>
 +#include "node.h"
 +
 +Node :: Node()
 +{
 + this -> next  = NULL;
 + this -> prev  = NULL;
 + this -> data  = NULL;
 + this -> value = 0;
 +}
 +
 +Node :: Node(int value)
 +{
 + this -> next  = NULL;
 + this -> prev  = NULL;
 + this -> data  = NULL;
 + this -> value = value;
 +}</code>
 +    * data.cc:<code c>
 +#include "node.h"
 +
 +Node * Node :: getData()
 +{
 + return (this -> data);
 +}
 +
 +void Node :: setData(Node *data)
 +{
 + this -> data = data;
 +}</code>
 +    * destroy.cc:<code c>
 +#include "node.h"
 +
 +Node :: ~Node()
 +{
 + this -> next  = NULL;
 + this -> prev  = NULL;
 + if (this -> data != NULL)
 + delete this -> data;
 +
 + this -> data  = NULL;
 + this -> value = 0;
 +}</code>
 +    * next.cc:<code c>
 +#include "node.h"
 +
 +Node * Node :: getNext()
 +{
 + return (this -> next);
 +}
 +
 +void Node :: setNext(Node *next)
 +{
 + this -> next = next;
 +}</code>
 +    * prev.cc:<code c>
 +#include "node.h"
 +
 +Node * Node :: getPrev()
 +{
 + return (this -> prev);
 +}
 +
 +void Node :: setPrev(Node *prev)
 +{
 + this -> prev = prev;
 +}</code>
 +    * value.cc:<code c>
 +#include "node.h"
 +
 +int Node :: getValue()
 +{
 + return (this -> value);
 +}
 +
 +void Node :: setValue(int value)
 +{
 + this -> value = value;
 +}</code>
 +\\
 +  * **/queue**
 +    * Makefile:<code c>
 +CFLAGS = -Wall
 +INC = -I ../../inc
 +AR = ar
 +CXX = g++ $(CFLAGS) $(INC) 
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +OBJ = $(SRC:.cc=.o)
 +LIB = $(shell /bin/pwd | /bin/sed 's/^.*\///')
 +all: $(SRC) $(OBJ) lib
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(OBJ) lib
 +
 +.cc.o:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -c $< && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -c $<
 +endif
 +
 +lib:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[L]   %-20s ... " "$<"
 + @$(AR) rcs ../../lib/lib$(LIB).a $(OBJ) && echo "SUCCESS" || echo "FAIL"
 +else
 + $(AR) rcs ../../lib/lib$(LIB).a $(OBJ)
 +endif
 +
 +
 +clean:
 + rm -f *.o $(OBJ) core</code>
 +    * create.cc:<code c>
 +#include "queue.h"
 +
 +Queue :: Queue()
 +{
 + // to be implemented
 +}
 +
 +Queue :: Queue(int size)
 +{
 + // to be implemented
 +}</code>
 +    * dequeue.cc:<code c>
 +#include "queue.h"
 +
 +Node * Queue :: dequeue()
 +{
 + // to be implemented
 +}</code>
 +    * destroy.cc:<code c>
 +#include "queue.h"
 +
 +Queue :: ~Queue()
 +{
 + delete this -> data;
 + this -> data   = NULL;
 + this -> bufsiz = 0;
 + this -> front  = NULL;
 + this -> back   = NULL;
 +}</code>
 +    * enqueue.cc:<code c>
 +#include "queue.h"
 +
 +void Queue :: enqueue(Node *newNode)
 +{
 + // to be implemented
 +}</code>
 +    * size.cc<code c>
 +#include "queue.h"
 +
 +int Queue :: getBufferSize()
 +{
 + // to be implemented
 +}
 +
 +void Queue :: setBufferSize(int size)
 +{
 + // to be implemented
 +}</code>
 +\\
 +  * **/stack**
 +    * **Makefile:**<code c>
 +CFLAGS = -Wall
 +INC = -I ../../inc
 +AR = ar
 +CXX = g++ $(CFLAGS) $(INC) 
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +OBJ = $(SRC:.cc=.o)
 +LIB = $(shell /bin/pwd | /bin/sed 's/^.*\///')
 +all: $(SRC) $(OBJ) lib
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(OBJ) lib
 +
 +.cc.o:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -c $< && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -c $<
 +endif
 +
 +lib:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[L]   %-20s ... " "$<"
 + @$(AR) rcs ../../lib/lib$(LIB).a $(OBJ) && echo "SUCCESS" || echo "FAIL"
 +else
 + $(AR) rcs ../../lib/lib$(LIB).a $(OBJ)
 +endif
 +
 +
 +clean:
 + rm -f *.o $(OBJ) core</code>
 +    * **create.cc:**<code c>
 +#include "stack.h"
 +
 +Stack :: Stack()
 +{
 + // to be implemented
 + // Call create(); from /src/list
 + // Set *top pointer.
 +
 + /*
 + Node *top;
 + this -> start = top;
 + this -> qty = 0;
 + */
 +}
 +
 +Stack :: Stack(int size)
 +{
 + return(getSize);
 +}</code>
 +    * **destroy.cc:**<code c>
 +#include "stack.h"
 +
 +Stack :: ~Stack()
 +{
 + delete this -> data;
 +// here I subconsciously did the "right thing"- set data to NULL immediately after calling delete on it
 + this -> data  = NULL;
 + this -> size  = 0;
 + this -> top   = NULL;
 +// a possible means of establishing sane behavior. This needs testing; it may not work here in the destructor.
 + this = NULL;
 +}
 +// NOTE: If the explicit "this = NULL;" line doesn't work, one will need to set the deleted pointer to NULL as an immediate next action.</code>
 +    * **peek.cc:**<code c>
 +#include "stack.h"
 +
 +Node * Stack :: peek()
 +{
 + return(stack.top)
 +}</code>
 +    * **pop.cc:**<code c>
 +#include "stack.h"
 +
 +Node * Stack :: pop()
 +{
 + // to be implemented
 +}</code>
 +    * **push.cc:**<code c>
 +#include "stack.h"
 +
 +void Stack :: push(Node *newNode)
 +{
 + // to be implemented
 +}</code>
 +    * **size.cc:**<code c>
 +#include "stack.h"
 +
 +int Stack :: getSize()
 +{
 + // to be implemented
 + // 1. Set *size to list.
 + // 2. Iterate through list while incrementing *size
 + // 3. return (size);
 +
 + // tmp variable for List.
 + List *tmp;
 + // i is an iterator.
 + int i = 0;
 + // Set tmp to the start of this.
 + tmp = this -> start;
 +
 + // Iterate through this while incrementing the node count i.
 + while (tmp != NULL)
 + {
 + // Count the node FIRST.
 + i = i + 1;
 + // Iterate tmp to the next node.
 + tmp = tmp -> getNext();
 + }
 +
 +return(tmp)
 +}
 +
 +void Stack :: setSize(int size)
 +{
 + this -> size = size;
 +}
 +
 +int Stack :: getListSize()
 +{
 + return (this -> getQuantity());
 +}</code>
 +\\
 +**/testing:**
 +  * **Makefile:**<code c>
 +CFLAGS = -Wall -L../lib -lqueue -lstack -llist -lnode
 +INC = -I ../inc/
 +CXX = g++ $(INC)
 +SRC = $(shell /bin/ls -1 *.cc 2>/dev/null)
 +BIN = $(SRC:.cc=)
 +all: $(SRC) $(BIN)
 +
 +debug: CXX += -DDEBUG -g
 +debug: DEBUG = debug
 +debug: $(SRC) $(BIN)
 +
 +.cc:
 +ifneq ($(MAKECMDGOALS),debug)
 + @printf "[B]   %-20s ... " "$<"
 + @$(CXX) -o $@ $< $(CFLAGS) && echo "OK" || echo "FAIL"
 +else
 + $(CXX) -o $@ $< $(CFLAGS)
 +endif
 +
 +clean:
 + rm -f *.o $(BIN) core</code>
 +  * **stacktest.cc**<code c>
 +#include <stdio.h>
 +#include "stack.h"
 +
 +int main()
 +{
 + Node *tmp = new Node;
 + Stack *myStack = new Stack(0);
 + tmp -> setValue(fgetc(stdin));
 + fgetc(stdin);
 +
 + while(tmp->getValue() != '\n')
 + {
 + myStack -> push(tmp);
 + tmp = new Node(fgetc(stdin));
 + fgetc(stdin);
 + }
 +
 + fprintf(stdout, "linked list has %d nodes\n", myStack -> getListSize());
 + fprintf(stdout, "String is: ");
 +
 + tmp = myStack -> pop();
 + while (tmp != NULL)
 + {
 + fprintf(stdout, "%c", tmp -> getValue());
 + delete tmp;
 + tmp = myStack -> pop();
 + }
 + while(tmp != NULL);
 +
 + fprintf(stdout, "\n");
 + return(0);
 +}</code>