I want to write my own version of stack, this is what I have:
template<class myStackType> class myStackClass
{
myStackType array[1000];
int size;
public:
myStackClass()
{
size = 0;
}
void pop()
{
size--;
}
void push(myStackType a)
{
array[size] = a;
size++;
}
myStackType top()
{
return array[size-1];
}
bool empty()
{
return(size == 0);
}
};
but when I try to actually use it
struct grade
{
int mid;
int final;
string name;
grade(int mid1 = 0, int final1 = 0, string name1 = 0)
{
mid = mid1;
final = final1;
name = name1;
}
};
myStackClass<grade> myStack;
I get a debug assertion failed: invalid null pointer
on the other hand, the std::stack works just fine in the same spot with the same data type
what am I doing wrong?
Thanks!