Hi,

I'm having a problem understanding this thing.
Suppose I have a function that returns a generic value.
Inside I have "try" and "catch" statements for exceptions.
Now once those exceptions have been detected, what and I mean in the name of Jesus butt-hole is my function suppose to return?

In my case I have a "clip" (first in last out) made out of templates.
I load it with pointers and then "eject". Once my clip is empty and I try to eject it, obviously that should considered as an exception. The problem is I do get the "failure" message as instructed but right after, the compiler crashes.

If anyone could shed some light on this, it'd be much appreciated.
Thank you.

Hi,

I'm having a problem understanding this thing.
Suppose I have a function that returns a generic value.
Inside I have "try" and "catch" statements for exceptions.
Now once those exceptions have been detected, what and I mean in the name of Jesus butt-hole is my function suppose to return?

In my case I have a "clip" (first in last out) made out of templates.
I load it with pointers and then "eject". Once my clip is empty and I try to eject it, obviously that should considered as an exception. The problem is I do get the "failure" message as instructed but right after, the compiler crashes.

If anyone could shed some light on this, it'd be much appreciated.
Thank you.

If your "clip" is a stack, why not make it so the eject returns a pointer to NULL when the list is empty?

T remove()
{  
   T *temp = 0;
   if(size > 0)
   {
      //code to remove and return T 
   }
   else
        return *temp;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.