The rethrown exception can have a different type. This compiles and runs correctly on VS2012:
#include <iostream>
int main() try
{
try
{
throw 20;
}
catch (int e)
{
std::cout << "An exception occurred. Exception Nr. " << e << std::endl;
throw std::string("abc");
}
}
catch (std::string const & ex)
{
std::cout << "Rethrow different type (string): " << ex << std::endl;
}
Output:
An exception occurred. Exception Nr. 20
Rethrow different type (string): abc