I am not able to understand, how following code is right,
class cls
{
//just to create obj
};
int main(int argc, char* argv[])
{
try
{
throw cls();//throwing obj as ref
}
catch(cls &ref)
{
}
return 0;
}
I am throwing cls
object as reference, will it not die as it comes out of { } scope?
Because catch block cannot access variables of try.