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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -