// except1.cc

#include <iostream.h>

class A
{
private:
  int max_level;
  int recurse (int level, int end);

public:
  A (int m) {max_level = m;}
  int call (int levels);
};


int A::recurse (int level, int end)
{
  if (level >= end)
    return (level);
  if (level >= max_level)
    throw level;
  return (recurse (level + 1, end));
}


int A::call (int levels)
{
  int r;

  try
    {
      r = recurse (0, levels);
    }
  catch (int x)
    {
      return (x);
    }
  return (r);
}


int main (void)
{
  A a(5);

  cout << a.call (2) << ' ' << a.call (10) << '\n';
  return 0;
}
