following code comipling perfectly but showing runtime error . why?
- by user323422
//sample.h
int calci(int &value)
{
if(value < 20)
throw value;
else
return value;
}
class XYX
{
int m_x;
public: XYZ(int &x)try:m_x(a-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(...){}
}