How can I use an array as map value?

后端 未结 8 1491
太阳男子
太阳男子 2020-12-01 08:04

I\'m trying to create a map, where the key is an int, and the value is an array as follows:

int red[3]   = {1,0,0};
int green[3] = {0,1,0};
int b         


        
8条回答
  •  清歌不尽
    2020-12-01 08:43

    Another alternative is to put the arrays in a wrapping struct:

        struct Wrapper { int value[3]; };
    
        // ...
        Wrapper red = {{1,0,0}};    
        std::map colours;    
        colours.insert(std::pair(1, red));
    

提交回复
热议问题