Exemplo
int
funct(){
int
exception = 2;
if
(exception){
throw
exception;
}
return
0;
}
int
main()
{
try
{
funct();
}
catch
(
int
ex) {
cout
<< ex;
}
return
0;
}
Solução
Capture uma referência para a exceção.
int
funct(){
int
exception = 2;
if
(exception){
throw
exception;
}
return
0;
}
int
main()
{
try
{
funct();
}
catch
(
int
& ex) {
cout
<< ex;
}
return
0;
}