c++ - Any way to use a method on a template class (when you have a pointer of a base class) when not knowing the used template type -


let's have :

class  {     virtual int method2(){/*...*/} };  template<typename t> class b<t> : public { public :     virtual int method1(){/*...*/}     virtual int method2(){/*...*/} }; 

is possible similar (this not work of course...) ?

a* = ...;  b* b = dynamic_cast<b*>(a);  b->method1(); 

thanks

what people have intermediary class.

class { virtual ~a() {} }; class b : public { virtual void method(); } template<typename t> class c : public b {     void method() { ... } };  a* = new c<int>(); if(b* b = dynamic_cast<b>(a)) {     b->method(); } 

this known type erasure. however, in system, doesn't serve purpose.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -