On Wed, 19 Nov 2003 19:27:41 +1030, "A" <A@iprimus.com.au> wrote:
What do you mean by propogate up? what goes up must come down again? and so
it repeats itself.
I mean propogate up the stack to the function that called the one the
throw; is in. I think you misunderstand what throw; actually does. It
doesn't rethrow the exception from where it was originally thrown, it
throws it from the point of the throw;. Here's an example:
#include <iostream>
class test_exception{};
void foo(int size)
{
std::cout << '3';
int* i = new int[size];
std::cout << '4';
try
{
std::cout << '5';
throw test_exception(); //*
std::cout << "Never here";
}
catch(...)
{
std::cout << '6';
delete[] i;
std::cout << '7';
throw; //throws the exception from here, not from *
std::cout << "Never here";
}
std::cout << "Never here";
}
int main()
{
std::cout << '1';
try
{
std::cout << '2';
foo(100);
std::cout << "Never here";
}
catch(test_exception const&)
{
std::cout << '8';
}
std::cout << '\n';
}
Tom