1

我有以下地图:

std::map<u_long, std::vector<CChatContainer*> >m_Container;

class CChatContainer
{
public:
    CChatContainer()
    {
        m_uStartPos = 0;
        m_uEndPos = 0;
        m_dwColor = NULL;
        m_pItemElem = NULL;
    }
    ~CChatContainer(){};

    u_long m_uStartPos;
    u_long m_uEndPos;
    DWORD m_dwColor;
    void* m_pItemElem;
};

如何在其中插入值,向量部分对我来说似乎很复杂

4

1 回答 1

1

例子:

u_long j = 2; // get index in the map - where to insert
std::vector<CChatContainer*> conts; // create container to insert
for( int i = 0; i < N; i++ ) { // fill the container
  CChatContainer* new_cont = new CChatContainer;
  cont.push_back(new_cont);
}

m_Container[j] = conts; // insert 
于 2012-08-22T00:19:43.450 回答