1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <vector>
#include <map>
#include <string>
int main ()
{
std::map<std::string, std::vector<float> > m_data;
std::vector<float> m_mass{1.0,3.0,5.0,7.0};
std::vector<float> m_velocity{1.0,3.0,5.0,7.0};
std::vector<unsigned int> m_charge{2,4,6,8};
m_data.insert(std::make_pair("mass", m_mass) );
m_data.insert(std::make_pair("velocity",m_velocity) );
m_data.insert(std::make_pair("charge", std::vector<float>(
m_charge.begin(), m_charge.end())) );
for(const auto p: m_data) {
std::cout << p.first << ": ";
for(const auto& n: p.second)
std::cout << n << ' ';
std::cout << '\n';
}
}
|
charge: 2 4 6 8
mass: 1 3 5 7
velocity: 1 3 5 7 |