Compiler Error C2531

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C2531.

identifier' : reference to a bit field illegal

References to bit fields are not allowed.

The following sample generates C2531:

// C2531.cpp  
// compile with: /c  
class P {  
   int &b1 : 10;   // C2531  
   int b2 : 10;   // OK  
};  

Show: