class A
{
public:
A(): a_(1.) {}
double f();
double g();
double a_;
};
double A::f()
{
double b = 2.;
try {
double a = 3.;
a += g();
b = a + a_;
//[...]
return b;
} catch (...) {
//[...]
}
return b;
}
double A::g()
{
double x = 5.;
return x;
}
The code is executed correctly, but when I debug f() breaking just before the catch I cannot see in a watch window the value of the variable a. Instead, I can see a_ (class member) and b (defined outside the try/catch block). I can also see x if I go inside g().
I've never had this problem with VS2005.
Dou you have any idea of what it's happening?
Well to start with you need to set the accessability of your class, like:
1 2 3 4 5 6 7 8 9 10
class A
{
public:
A(): a_(1.) {}
double f();
double g();
private:
double a_;
};
So that we can actually test it.
Then, when you debug the code you will find that your debugger will only be aware of the variable 'a' inside the try...catch block as it is only declared within that block i.e. it doesn't exist outside. If you are using Visual Studio you will be able to see the values of variables in the 'Autos' 'Locals' windows the 'Watch' window will only show you the values of variables that are both currently in scope and that you have specified you want to watch.
Of course ajh32
(thank you for replying)
this is a very simplified code, as an example of a more general problem.
Think that A is a struct, or else that there is a public. I just edited the code adding the public keyword.
My problem is that if I put a breakpoint at line 18 I should see the value of a, a_ and b, instead I cannot see a.
In the watch window, where I put a, I read
CXX0017:Error:symbol a not found
That's why I say it's strange...
I really don't know how to investigate the origin of the issue.
Maybe some debugging configuration?
Maybe something related with x64 application? I see that there are other issues about debugging a x64 application in VS2008, for exampe Edit&Continue is not supported.