Fun with Fruit (or Spy vs Spy revisited)

I had forgotten about this code sample until recently. Oren Miller and I wrote this a few years ago to explore how setjmp and longjmp work. Your mission (if you choose to accept it) is to scan the code below and see if you can write down the print-out order of the fruit names. Then, copy the code to a .cpp file, compile it, and run the program to see how close you got. (This was written with VC++ 6, and I just tried it with VS.NET2003 and it worked, also many thanks to doxygen for the text formatting to give the code some color):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Fruit
 
 // For Your Viewing Pleasure
 // Please Enjoy the Fruits of our Labors
 #include <setjmp.h>
 #include <iostream>

 typedef int Grenade;
 jmp_buf target = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

 class BlueSpy
 {
 public:
         BlueSpy()
         {
                 long val = setjmp( target );
                 if( val != 42 ) Chuck(Grenade(42));
                 std::cout << "APPLE\n";
         }

         ~BlueSpy()
         {
                 std::cout << "TANGERINE\n";
                 longjmp(target, 42);
                 std::cout << "COCONUT\n";
         }

         static void Chuck( Grenade a_Grenade )
         {
                 std::cout << "PINEAPPLE\n";
                 throw a_Grenade;
         }
 };

 class RedSpy
 {
 public:
         RedSpy()
         {
                 long val;
                 try
                 { 
                         BlueSpy* blue = new BlueSpy();
                         val = setjmp( target );
                         std::cout << "ORANGE\n";
                         if(val != 42)
                                 delete blue;
                 } 
                 catch(Grenade frag)
                 {
                         ChuckBack(frag);
                         std::cout << "GRAPE\n";
                 }
                 std::cout << "PEAR\n";
         }

         ~RedSpy()
         {
                 std::cout << "KIWI\n";
                 BlueSpy();
                 throw Grenade();
         }

         static void ChuckBack( Grenade a_Grenade )
         {
                 std::cout << "MANGO\n";
                 longjmp(target, a_Grenade);
         }
 };

 int main()
 {

         std::cout << "BANANA\n";
         try {

                 RedSpy red;
         } catch(Grenade) {
                 std::cout << "GRAPEFRUIT\n";
         }

         std::cout << "STRAWBERRY\n";

         return(0);
 }