Compiler Error C2451

 

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

conditional expression of type 'type' is illegal

The conditional expression evaluates to an integer type.

The following sample generates C2451:

// C2451.cpp  
class B {};  
  
int main () {  
   B b1;  
   int i = 0;  
   if (b1)   // C2451  
   // try the following line instead  
   // if (i)  
      ;  
}  

Show: