Related to a different question I have posted for which I am trying to find a solution some how - C++ dynamic way to determine the container to use
Noticed similar links:
How to use a string as a variable name in C++?
How to adress variable by name stored in another variable (C++)
Edited - From int to float..
Edit 2 - the following seems to have some solution for this at this link - but need to somehow translate for this problem at hand..
How to create instance of a class when the class name is stored in another variable
I have the following structure:
Class Items
{
float itemType;
float itemPrice;
Items(){};
~Items(){};
};
typedef std::unique_ptr<Items> pptr;
typedef std::pair<float, pptr> itemsRec;
std::multimap<float, pptr> mapItems;
Need help with creating a new map of mapItems... can any one help with the syntax to create this new map of mapItems? Let's assume "A" gets derived by other means.
Thanks
std::map<string, pointer to mapItems> myMap; // What's the syntax for this?
myMap["A"]={create a new map - mapItems_A and assign pointer here};
Thanks.
Edit 3 - Still exploring options - Looks like the following link has some interesting stuff that might be helpful in my case to define the container dynamically.. Exploring further.
http://sourcemaking.com/design_patterns/factory_method/cpp/1#