C
chirag
i wrote the following code for the comments given. however, i am getting
some errors in it. it says local function definitation are illegal.. plese
scan through the following code. thanks.
void Stack:rint()
// Prints the contents of a stack from top to bottom. The stack
// is not changed. Does not call any Stack member functions.
{
int item;
if (aList.isEmpty())
throw StackException("Cannot print, stack is empty.");
cout << "The contents of a stack are : ";
for (int i = 1; i <= aList.getLength(); i++)
{
try
{
aList.retrieve(i, item);
}
catch (ListIndexOutOfRangeException e)
{
throw StackException("Retrieve index out of range");
}
cout <<item << " ";
}
}
some errors in it. it says local function definitation are illegal.. plese
scan through the following code. thanks.
void Stack:rint()
// Prints the contents of a stack from top to bottom. The stack
// is not changed. Does not call any Stack member functions.
{
int item;
if (aList.isEmpty())
throw StackException("Cannot print, stack is empty.");
cout << "The contents of a stack are : ";
for (int i = 1; i <= aList.getLength(); i++)
{
try
{
aList.retrieve(i, item);
}
catch (ListIndexOutOfRangeException e)
{
throw StackException("Retrieve index out of range");
}
cout <<item << " ";
}
}