//sample.h
int calci(int &value)
{
if(value < 20)
throw value;
else
return value;
}
class XYZ
{
int m_x;
public: XYZ(int &x)try:m_x(x-calci(x))
{
}catch (int &a)
{}
};
class ABC
{
int m_a;
public: ABC():m_a(0)
{
}
void foo()
{
XYZ xyz(10);
}
};
int main()
{
ABC abc;
abc.foo();
}
//if i replace foo() with following code then it works well
void foo()
{
try{
XYZ xyz(10);
}catch(...){}
}