G
George2
Hello everyone,
In the sample, I am wondering what is the life cycle of variable b_?
Could we access variable b_ in catch block?
I have this confusion is because,
1. I think b_ is member variable, and we should be able to access it
anywhere in the class itself, so we can access b_ in catch block;
2. I think b_ is declared and initialized in try {} block, and catch
exceeds the {} of try, so we can not access b_ in catch block.
Which option is correct?
http://www.gotw.ca/gotw/066.htm
thanks in advance,
George
In the sample, I am wondering what is the life cycle of variable b_?
Could we access variable b_ in catch block?
I have this confusion is because,
1. I think b_ is member variable, and we should be able to access it
anywhere in the class itself, so we can access b_ in catch block;
2. I think b_ is declared and initialized in try {} block, and catch
exceeds the {} of try, so we can not access b_ in catch block.
Which option is correct?
http://www.gotw.ca/gotw/066.htm
Code:
class C:
{
B b_;
C::C()
try
: b_( /*...*/ )
{
}
catch( ... )
{
// can we access _b here?
}
};
thanks in advance,
George