1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <iostream>
#include <map>
using namespace std;
int main()
{
typedef map<string, string> TAction;
TAction mapAction;
//Création de la map
mapAction.insert(TAction::value_type("i456", "contrôler le serrage de l'ampoule"));
mapAction.insert(TAction::value_type("i457", "contrôler l'alimentation de l'ampoule"));
mapAction.insert(TAction::value_type("i458", "contrôler le bouton"));
//Exemple de recherche
std::string a = "i456";
if( mapAction.find(a) != mapAction.end() )
{
cout<<mapAction[a]<<std::endl;
}
else
{
cout<<"Cette action n'est pas reconnue\n";
}
return 0;
} |