following code comipling perfectly but showing runtime error . why?
Posted
by user323422
on Stack Overflow
See other posts from Stack Overflow
or by user323422
Published on 2010-04-30T09:04:59Z
Indexed on
2010/04/30
9:07 UTC
Read the original article
Hit count: 174
c++
|exception-handling
//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(...){}
}
© Stack Overflow or respective owner