[Solved] C++ dynamic way to determine the container to use


You seem to be getting an awful lot of different concepts confused, certainly more than could be sorted out in this form.

One way to solve this would be a base class Product from which all your various “product types” derive, solving your first bullet point neatly, as any standard container could hold various types with a common base class.

But your description is so nebulous that I cannot tell if this would even be a viable solution for you…

My impression is that you are trying to solve advanced producer / worker problems without basic experience with OOP and C++. Start at the beginning, and work patiently through the examples of types, classes, objects and inheritance. If you do that, not only might you develop a better idea of what you are actually trying to achieve. You will also develop the vocabulary to ask questions in a way that could be answered with likewise precision. (Like, whether we are looking at a single-threaded “homework” style program, a multithreaded application, or multiple processes communicating with each other — I am still not sure about that one.)

As it is, all we can do is guessing, and drivel in the general direction of what might or might not be a solution for what we understand might be your problem…

3

solved C++ dynamic way to determine the container to use