vendredi 7 décembre 2018

how to handle different structues with a single c++ class member?

I am having a c++ class, A provision should be given to User to input different kinds of custom structures ex:

struct user1 {
        int var1;
        char var2;
};

struct user2 {
    vector<int> vecArr(5);
};

class {
    // need store a structure obj here.
};

the class is supposed to store the structures of above. how to create a generic class that can handle different type of structures?

senario: Once the structure used to create instance of class, its not changed. each class object will have only one strucutre.

Thanks, Vivek.

Aucun commentaire:

Enregistrer un commentaire