templates - Adding values from file to a hash type structure in C++ -
I have a separate file from a location that contains some key-> value pairs. To be loaded:
#define FV_PARAM1 "A" #define FV_PARAM2 "B" parameter_T & amp; ParameterFactoryVector (parameter_t and ultimate, int parameter, int paragraph,) {param.addParam (FV_ PARAM1, paragraph 1); Param.addParam (FV_PARAM2, absolute 2); Return supreme; } So for the above, I can pass the following values:
parameterFeatureVector (10, 20); And I hope that the same will be loaded into the 'ultimate' structure. The above value is taken from the file. How do I apply it? If the above is not clear, feel free to withdraw it.
I take it to you, how to translate the name "A" for a specific composition area Is asking If so, there is no built-in method to do this in C ++ - you have to type a function:
Add zero (parameter_t and p, const strode :: string and name, int Value) {If (name == "A") {p.param1 = value; } And if (name == "b") {p.param2 = value; } And if (....) {// more name test here}} However, I would suggest not to do this, and instead use a map:
std :: map & lt; Std :: string, int & gt; Parameter; Then you can say things like:
consultation ["A"] = 42;
Comments
Post a Comment