C++ Vector of Maps using an iterator how to

前端 未结 2 1208
时光取名叫无心
时光取名叫无心 2021-01-26 12:36

How can I populate a vector of map along with a rowID , or an iterator for each row of a valuepair Set

Like for example

typedef std::map

        
2条回答
  •  隐瞒了意图╮
    2021-01-26 12:56

    in short:

    mapDB_vec.push_back(std::make_pair(0, mapDB_colVal));
    

    longer:

    you don't need that rowID, vector index is good enough

    more longer:

    struct Row {
        std::string x;
        std::string y;
    
        Row(std::string const& x_, std::string const& y_): x(x_), y(y_)
        {}
    };
    
    vector mapDB_vec;
    mapDB_vec.push_back(Row("Apple", "Red"));
    mapDB_vec.push_back(Row("Pear", "Red"));
    

提交回复
热议问题