Character Array as a value in C++ map

后端 未结 4 1236
一个人的身影
一个人的身影 2021-01-05 13:38

I want to define something like

Map myMap;

The above declaration is accepted by c++ compiler and no error is thrown bu

4条回答
  •  不思量自难忘°
    2021-01-05 14:31

    You cannot use an array in a standard container.

    1. Use an std::vector instead of an array

    2. Use a map of pointers to arrays of 5 elements.

    3. Use boost tuples instead of arrays of 5 elements.

    4. Instead of using an array make a new struct that takes 3 elements. Make the map. Or wrap your array in a struct and that will work too.

    \

    struct ArrayMap
    {
        int color[5];
    };
    

    /

提交回复
热议问题