Loesome

Test.h

Apr 8th, 2014
762
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef STACKADT_H
  2. #define STACKADT_H
  3. #include <Stack.h>
  4. #include <stdlib.h>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8. template <typename E> class StackADT : public Stack<E>
  9. {
  10. private:
  11.     void operator =(const StackADT&) {}
  12.     StackADT(const StackADT&) {}
  13.     E *stack;
  14.     int  top = 0;
  15.  
  16. public:
  17.     StackADT() {
  18.         stack = new E[2];
  19.     }
  20.     ~StackADT() {}
  21.  
  22.     void clear(){
  23.         top = 0;
  24.     }
  25.     void push(const E& it){
  26.         if(top < sizeof(stack)){
  27.             stack[top] = it;
  28.             top++;}
  29.         else{
  30.             stack = (E *) realloc( stack, 2*sizeof(E));
  31.             stack[top] = it;
  32.             top++;
  33.  
  34.         }
  35.     }
  36.     E pop(){
  37.         E aux = stack[this->top - 1];
  38.         this->top--;
  39.         return aux;
  40.     }
  41.     const E& topValue()const{
  42.         return stack[top - 1];
  43.     }
  44.     int length()const{
  45.         return top;
  46.     }
  47.  
  48. };
  49.  
  50.  
  51. #endif // STACKADT_H
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×