Stack data structure using Templates
I swear lately, i'm not getting anything right..and it is p*s**ng me off...this is what happens when I leave C++ to do something else...argh
Code:
template<typename T>
class MyOwnStack
{
public:
void push(T x);
T pop() ;
MyOwnStack(int x) ;
private:
T *a ;
int index;
};
template<typename T> MyOwnStack<T>::MyOwnStack(int x)
{
a = new T[x];
}
template<typename T> MyOwnStack::push(T x)
{
a[index++] = x ;
}
template<typename T> T MyOwnStack<T>::pop()
{
int a = a[index--];
return a;
}
int main()
{
return 0;
}
Dev C++ doesn't compile this code, Vis Studio doesn't as well..i really don't know wtf is going wrong..can anyone enlighten me? Thanks