
Untitled
By: a guest on
Jun 14th, 2012 | syntax:
None | size: 1.62 KB | hits: 23 | expires: Never
#include "StdAfx.h"
#include "twoStacksOneArray.h"
#include <iostream>
using namespace std;
template <class T>
twoStacksOneArray<T>::twoStacksOneArray(void)
{
indexa=0;
indexb=size-1;
}
template <class T>
twoStacksOneArray<T>::~twoStacksOneArray(void)
{
delete [] arr;
}
template <class T>
void twoStacksOneArray<T>::aPush(T val)
{
if(indexa < 5)
arr[indexa++]=val;
else
cout<<"This Stack is Full!"<<endl;
}
template <class T>
void twoStacksOneArray<T>::bPush(T val)
{
if(indexb >= 5)
arr[indexb--]=val;
else
cout<<"This Stack is Also Full!"<<endl;
}
template <class T>
T twoStacksOneArray<T>::aPop()
{
if(!isaEmpty())
return arr[(indexa--)-1];
else
cout<<"This Stack is Empty!"<<endl;
return NULL;
}
template <class T>
T twoStacksOneArray<T>::bPop()
{
if(!isbEmpty())
return arr[(indexb++)+1];
else
cout<<"This Stack is Empty!"<<endl;
return NULL;
}
template <class T>
bool twoStacksOneArray<T>::isaEmpty()
{
return indexa==0;
}
template <class T>
bool twoStacksOneArray<T>::isbEmpty()
{
return indexb==size-1;
}
template <class T>
twoStacksOneArray<T>::twoStacksOneArray(twoStacksOneArray &a)
{
this->indexa = a.indexa;
this->indexb = a.indexb;
for(int i=0 ; i < size ; i++)
this->arr[i] = a.arr[i];
}
int _tmain(int argc, _TCHAR* argv[])
{
twoStacksOneArray<int> *t = new twoStacksOneArray<int>();
return 0;
}
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