That's right @expor..thanks
Still I get two errors in the generic stack
Here is the pop() definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
//definition of pop
template <class StackType> StackType stack<StackType>::pop()
{
if(top == -1)
{
cout << "Stack is empty";
return (StackType)0 ; /*This line gives the error when addresses are popped from stack */
}
else
{
StackType item = stck[top] ;
if(top == 0)
{
top = -1 ;
}
else
{
top = top - 1 ;
}
return item;
}
}
|
I have not defined any top function , it is a variable .
If top = -1 , it means stack is empty
if top = sizeOfArray -1 , it means stack is full.
Also , the error is generated by the code within main by the following line
|
cout << array4.pop() << endl ;
|
Errors are as follows:
1. no matching function for call to address::address(int)
2. no match for operator in std::cout << stack<StackType>::pop [with StackType = address]()
Any suggestions about that ?