Working on a console application and I am trying to figure out a way that allows users to enter an object property along with a value. For example
For example if a user inputs "height" for Name and "13" as value I would like to find a way to change ab's height to 13. I want to make this work so that one can add another class and get the same functionality.HTML Code:class Box{ public: int height; int width; int length; }; int main(){ Box ab; string Name,value cin>>Name>>value; map<string,string> propMap propMap[name] = value; }
I tried looking online and I think maps are a way to do this and I tried doing that but I don't know how to proceed after/what code to write that would allow me to change it.
Note: I can't use if else statements or hardcoding to match the input to member as I want to make this extensible.




Reply With Quote
