Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 14th, 2012  |  syntax: None  |  size: 1.62 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "StdAfx.h"
  2. #include "twoStacksOneArray.h"
  3. #include <iostream>
  4. using namespace std;
  5. template <class T>
  6. twoStacksOneArray<T>::twoStacksOneArray(void)
  7. {      
  8.         indexa=0;
  9.         indexb=size-1;
  10. }
  11. template <class T>
  12. twoStacksOneArray<T>::~twoStacksOneArray(void)
  13. {
  14.         delete [] arr;
  15. }
  16. template <class T>
  17. void twoStacksOneArray<T>::aPush(T val)
  18. {
  19.         if(indexa < 5)
  20.         arr[indexa++]=val;
  21.         else
  22.                 cout<<"This Stack is Full!"<<endl;
  23.  
  24. }
  25. template <class T>
  26. void twoStacksOneArray<T>::bPush(T val)
  27. {
  28.         if(indexb >= 5)
  29.                 arr[indexb--]=val;
  30.         else
  31.                 cout<<"This Stack is Also Full!"<<endl;
  32. }
  33.  
  34.  
  35. template <class T>
  36. T twoStacksOneArray<T>::aPop()
  37. {
  38.         if(!isaEmpty())
  39.                 return arr[(indexa--)-1];
  40.         else
  41.                 cout<<"This Stack is Empty!"<<endl;
  42.         return NULL;
  43. }
  44. template <class T>
  45. T twoStacksOneArray<T>::bPop()
  46. {
  47.         if(!isbEmpty())
  48.                 return arr[(indexb++)+1];
  49.         else
  50.                 cout<<"This Stack is Empty!"<<endl;
  51.         return NULL;
  52. }
  53.  
  54. template <class T>
  55. bool twoStacksOneArray<T>::isaEmpty()
  56. {
  57.         return indexa==0;
  58. }
  59.  
  60. template <class T>
  61. bool twoStacksOneArray<T>::isbEmpty()
  62. {
  63.         return indexb==size-1;
  64. }
  65.  
  66.  
  67. template <class T>
  68. twoStacksOneArray<T>::twoStacksOneArray(twoStacksOneArray &a)
  69. {
  70.         this->indexa = a.indexa;
  71.         this->indexb = a.indexb;
  72.         for(int i=0 ; i < size ; i++)
  73.                 this->arr[i] = a.arr[i];
  74.  
  75. }
  76.  
  77.  
  78.  
  79. int _tmain(int argc, _TCHAR* argv[])
  80. {
  81.         twoStacksOneArray<int> *t = new twoStacksOneArray<int>();
  82.  
  83.        
  84.         return 0;
  85. }
  86.  
  87.  
  88.  
  89.  
  90. Error   1       error LNK2019: unresolved external symbol "public: __thiscall twoStacksOneArray<int>::twoStacksOneArray<int>(void)" (??0?$twoStacksOneArray@H@@QAE@XZ) referenced in function _wmain    Testing.obj