Compiler Error C2166

 

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 C2166.

l-value specifies const object

Code attempts to modify an item declared const.

The following sample generates C2166:

// C2166.cpp  
int f();  
int main() {  
   ( (const int&) 1 ) = 5;   // C2166  
}  

Show: