c++ - Accessing a std::map of std::map like an array -


I started a std :: map of the std :: map as the following:

  static std :: map & lt; std :: string, std :: map & lt; Std :: string, float & gt; & Gt; _ScalingMapFrequency = {{"mHz", {{"mHz", 1.0}}}, {"mHz", {{"Hz", 1e-3}}}, {"hertz", {{"mHz", 1e + 3}}}, {"hertz", {{"Hz", 1.0}}}};   

And now I am trying to use float values ​​in the following values:

  std :: cout < & Lt; "Scaling factor is:" & lt; & Lt; _ScalingMapFrequency ["MHz"] ["Hertz"];   

When I compile and run the code, but I expect to get "1e-3", then I'm always getting "0". I need to reach the std :: map "_ScalingMapFrequency" as an array, due to this design decision,

What am I doing wrong? Please give me some indicators and I would greatly appreciate it. A map can not be a duplicate key, so when you do {"mHz", {{"Hertz", 1e-3}}, for the second time, it merge first, as if to merge them Is opposed.

You should change the constructor so that they can merge {{"{{" {{{{Hz}, 1e-3}}, " <" > <">"

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -