Compiler Error C2683


For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

'cast' : 'type' is not a polymorphic type

You cannot use dynamic_cast to convert from a non-polymorphic class (a class with no virtual functions).

You can use static_cast to perform conversions of non-polymorphic types. However, static_cast does not perform a run-time check.

The following sample generates C2683:

// C2683.cpp  
// compile with: /c  
class B { };  
class D : public B { };  
void f(B* pb) {  
   D* pd1 = dynamic_cast<D*>(pb);  // C2683  
   D* pd1 = static_cast<D*>(pb);   // OK