Compiler Error C2680

'type' : invalid target type for name

An attempt was made to use a casting operator to convert to a type that is not a pointer type or a reference type. The dynamic_cast operator can be used only for converting to pointers or references.

The following is an example of this error:

class A { virtual void f(); };
class B : public A {};

void g(B b)
{
    A a;
    a = dynamic_cast<A>(b);  // error
}