J
j_depp_99
The program below fails on execution and I think the error is in my
pop function but it all looks correct.Also could someone check my code
as to why my print function is not
working? I havent included the other parts of my program but will if
someone needs it. Please help; I have had it. I have checked all C++
websites and cannot figure it out.
<code>
template<class Type>
void Novice<Type>:rint()
{
while(! IsEmpty())
{
std::cout << topPtr->item;
topPtr = topPtr ->next;
}
}
template<class Type>
void Novice<Type>:op(Type &y)
{
if(IsEmpty())
throw EmptyStack();
else
{
Node<Type> *tempPtr;
tempPtr = topPtr;
topPtr = topPtr -> next;
delete tempPtr;
}
}
// main function
int main()
{
Novice<int> a;
int s;
a.Pop(s); // not working
a.Push(1);
a.Push(2);
a.Push(3);
cout << a.length() << endl;
a.Pop(s);
cout << a.length() << endl;
a.Print();
}
</code>
pop function but it all looks correct.Also could someone check my code
as to why my print function is not
working? I havent included the other parts of my program but will if
someone needs it. Please help; I have had it. I have checked all C++
websites and cannot figure it out.
<code>
template<class Type>
void Novice<Type>:rint()
{
while(! IsEmpty())
{
std::cout << topPtr->item;
topPtr = topPtr ->next;
}
}
template<class Type>
void Novice<Type>:op(Type &y)
{
if(IsEmpty())
throw EmptyStack();
else
{
Node<Type> *tempPtr;
tempPtr = topPtr;
topPtr = topPtr -> next;
delete tempPtr;
}
}
// main function
int main()
{
Novice<int> a;
int s;
a.Pop(s); // not working
a.Push(1);
a.Push(2);
a.Push(3);
cout << a.length() << endl;
a.Pop(s);
cout << a.length() << endl;
a.Print();
}
</code>