This question is closely related to a subsequently asked question here.
The method of defining in-class constants is described here by Stroustrup.
When I follow Stroustrup's method I see the expected results. However, in Visual Studio 2010, the debugger cannot resolve a static const
class member within that class's scope.
Here is what I mean:
#include <iostream>
class Foo {
public:
static const int A = 50;
char arr[A];
void showA();
};
void Foo::showA() {
std::cout << "showA = " << A << "\n";
}
int main() {
Foo f;
f.showA();
}
When the debugger is in showA() the "watch" window reports:
Error: Symbol "Foo::A" not found
I'd like to emphasize that the program does behave as expected i.e. the output is:
showA = 50
and the program returns 0.
Can anyone else reproduce this with Visual Studio 2010? Is this a bug in the debugger?