c++ - Why does local struct with in-class initializer hide class' variables? -


consider code:

class { public:   void f();  private:   int foo; };  void a::f( ) {   struct s   {     int bar = 100;   } s;    s.bar = foo; } 

this won't compile vs2013 giving c2327 , c2065 errors on last line. however, if delete initializer or put struct declaration outside compile. bug or standard behavior?
edit: question being complete here error messages:

error c2327: 'a::foo' : not type name, static, or enumerator
error c2065: 'foo' : undeclared identifier

the code fine vs2015 rc (ultimate). vs 2013 has bug in class initialization. following code works vs 2013

class { public:     void f(); private:     int foo; };  void a::f( ) {     struct s     {         int bar;         s(int b = 0) : bar{b} {}     } s;      s.bar = foo; } 

Comments