c++ cli - Unable to use dynamic_cast with generics -


i have generic class client has single type parameter. type parameter reference type derived base. declare class below:

generic <class t> t : base, gcnew() public ref class client {   t val;   void setval(base ^bval){      val = dynamic_cast<t>(bval);  // error c2682: cannot use 'dynamic_cast' convert 'base ^' 't'    }   }; 

why compile error when using dynamic_cast convert base 1 of derived classes? expecting cast compile fail @ runtime (by returning nullptr) in case argument of incorrect type.

try dynamic_cast <t^>.

pointers have cast other pointers, handles other handles, , forth.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -