|
Boost : |
From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-08-15 03:27:35
Thank you for the example. I guess I hadn't paid as close attention to the
last paragraph of 14.3.1 of Stroustrup 3rd ed. as I thought.
At Wednesday 2002/08/14 10:53, you wrote:
>From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
> > >
> > >Well, I am not a compiler writer, but it seems to me that to implement
> > >"throw;" and "catch", the compiler already needs a way to copy the
> > >exception, complete with its original type. :-)
> >
> > I don't see that at all. The catch() clause specifies the type it's
> > expecting and it will be copied and sliced if need be to match.
>
>Quiz: what does this program do?
>
>#include <iostream>
>
>struct X
>{
>};
>
>struct Y: public X
>{
>};
>
>void f()
>{
> try
> {
> throw Y();
> }
> catch(X)
> {
// an exception will be caught here.
> throw;
// an exception of type Y will be thrown.
> }
>}
>
>int main()
>{
> try
> {
> f();
> }
> catch(Y)
> {
// an exception will be caught here.
> std::cout << "Caught an Y!\n";
> }
>}
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk