From this answer qaru.site/questions/1004509 / ... :
An expression expression without operands returns the current exception handling. The exception is renewed with the existing temporary; no new temporary exception object is created. - ISO / IEC 14882: 2011 Clause 15.1 par. 8
So why am I getting this result from this code?
the code:
#include <iostream>
class my_exception: public std::exception{
public:
int value;
};
int main()
{
my_exception ex;
ex.value=1;
try{
throw ex;
}
catch(my_exception& e){
e.value=2;
}
std::cout << ex.value;
return 0;
}
Actual result:
1
I thought it should be 2 depending on the standard quota. What am I missing?
source
share