Hello. There was a need to implement a dynamic structure (linear) filled with class template objects, but since the type parameters are different, I created a dynamic structure of pointers to void to fill in a dynamic structure using the function.
But now the question arose: is there a way to get access to the desired object? Or is it possible to implement this task more easily?
Code:
struct InfoForUI { std::string name; void* VectorClass; }; struct ListForClass { InfoForUI info; ListForClass* next; }; class UIforClass { public: ListForClass *head; UIforClass() { head = NULL; } ~UIforClass(); void Add() { //тут интерфейсная часть Vector <char> *obj = new Vector <char>; std::cin >>*obj; temp->info.VectorClass = obj; } }; Forgive help advice.
std::vector. And what STL does not like? - SuperDimon007int,doubleand others, and then you need, for example, for thek-th element to determine the type, and not only to determine, dynamically at runtime ... I think it is necessary change the approach itself. Is it possible, for example, to reduce the original task to the storage of class hierarchy objects with virtual methods? - Harry