Map 与结构体的混合使用

#include <iostream>
#include <map>
 
using namespace std;
 
typedef struct alertInfo {
    double alertUp;
    double alertDown;
    alertInfo(double up, double down) {
        alertUp = up;
        alertDown = down;
    };
} alert;
 
int main()
{
    map<int, alert> alert_map;
 
    for (int i = 0; i < 10; i++) {
        alert_map.insert(pair<int, alert>(i, alert(240 * i, 200)));
    }
 
    for (auto it = alert_map.begin(); it != alert_map.end(); ++it) {
        cout << it->first  << " - > " << it->second.alertUp << endl;
    }
}
原文地址:https://www.cnblogs.com/zhaopengpeng/p/13393347.html