c++ getting dynamic generic type of pointer?

the title probably is misleading, but i didn't really know how to name it.

let's say I have the following structs

template <typename T>
struct SillyBase{
   void doFunnyStuff(vector<T> vec){
        dummyField = T();
        for(int i=0; i<10; i++)
    T dummyField;

struct A : public SillyBase<char>{};

struct B : public SillyBase<float>{};

now let's further assume i have a pointer

ISillyBase* ptr;

which is pointing to an object of a DECENDANT class (A or B) of SillyBase - however, i DON'T KNOW which one (i just know it's either A or B);

Is there ANY way for me to call doFunnyStuff() ?

maybe something like:

vector<dynamic_generic_type_of(ptr)> vec;



In your example you can't have SillyBase* because SillyBase is defined as

template <typename T> struct SillyBase {...}

So you need to provide type ...

Another problem is that you pass a copy of vector<T> into doFunnyStuff() which you then populate ... that does not seems right because when the method returns you lose your vec, was it supposed to be reference vector<T>& ?

Need Your Help

Setting a read only Textbox default Backcolor

c# winforms colors textbox

I have a TextBoxwhich is set to be ReadOnly.

Unusual email showing up

smtp email-spam

I wrote an smtp app as an experiment. It saves everything it gets and doesn't validate the to address. I forgot I left it running and when I went back to turn it off I noticed all these heard only ...