map 装struct

#include <vector>
#include <iostream>
#include "compacket.h"
#include <map>
using namespace std;

struct Activity
{
 int m_nStep;
 int m_nCount;
 Activity():
  m_nStep(1),m_nCount(0)
 {
 }
 Activity(const int nStep,const int nCount):
  m_nStep(m_nStep = nStep),m_nCount(m_nCount = nCount)
 {
 }
};

int main()
{
 map <int ,Activity> test;
 test[1001] = Activity(1,10);
 cout<<"ID:"<<1001<<"步骤:"<<test[1001].m_nStep<<"人数:"<<test[1001].m_nCount<<endl;

 return 0;
}

原文地址:https://www.cnblogs.com/byfei/p/3112255.html