June 04, 2003
Hi guys,

I've actually start taking C++ programming classes again (first time since
1995) to prepare for the inevitable! (D)

I'm trying to implement an Array List ADT from which I've got to throw bad_alloc and logic_error exceptions.  I've pretty much completed the implementation, however I am having a little bit of a problem understanding this concept.  Would someone mind explaining and demonstrating how to use throw to guard against overrunning the array in the following insert function?

void List:: insert ( const T &item ) throw ( logic_error )
{
  if ( !Full() )
  {
    container[ ++position] = item;
    size++;
  }
  else
    return;
}

Andrew


June 16, 2003
It will automatically throw an ArrayBoundsException, no extra coding necessary.

"Andrew Edwards" <edwardsac@spamfreeusa.com> wrote in message news:bbk9kf$2r14$1@digitaldaemon.com...
> Hi guys,
>
> I've actually start taking C++ programming classes again (first time since
> 1995) to prepare for the inevitable! (D)
>
> I'm trying to implement an Array List ADT from which I've got to throw bad_alloc and logic_error exceptions.  I've pretty much completed the implementation, however I am having a little bit of a problem
understanding
> this concept.  Would someone mind explaining and demonstrating how to use throw to guard against overrunning the array in the following insert function?
>
> void List:: insert ( const T &item ) throw ( logic_error )
> {
>   if ( !Full() )
>   {
>     container[ ++position] = item;
>     size++;
>   }
>   else
>     return;
> }
>
> Andrew
>
>