Victor Bazarov wrote:[color=blue]
> "Michael Etscheid" <the.michael.e@gmail.com> wrote...
>[color=green]
>>Victor Bazarov schrieb:
>>[color=darkred]
>>>>e) is the first catch statement is used or the best match is used in a
>>>>catch block
>>>
>>>
>>>The best match.[/color]
>>
>>That's not true. The first statement that maches is used.[/color]
>
>
> So, if the "first catch statement" doesn't match, it is not used, right?
> Read the question again.
>
>[/color]
Without the testosterone <g>:
struct base {};
struct derived : base {}
void f()
{
try {
throw derived();
}
catch(int)
{
cout << "We never get here.\n";
}
catch(const base&)
{
cout << "We get here, 'cause this is the first match.\n"
}
catch(const derived&)
{
cout << "We don't get here, even though "
"this is the 'best' match.\n"
}
Naturally, this explains why catch(...) should only be used as the last
catch clause in a series.
--
Pete Becker
Dinkumware, Ltd. (
http://www.dinkumware.com)