Exemple

int funct(){
int exception = 2;
if(exception){
throw exception;
}
return 0;
}

int main()
{
try {
funct();
}
catch (int ex) {
cout << ex;
}
   
return 0;
}

Solution
Interceptez une référence à l'exception.

int funct(){
int exception = 2;
if(exception){
throw exception;
}
return 0;
}

int main()
{
try {
funct();
}
catch (int &ex) {
cout << ex;
}
   
return 0;
}