2013-02-27 3 views
0

Quelqu'un sait comment produire une variable struct qu'il est entré dans une map.how non ordonnée pourrait-je obtenir dictionary-> mot par exemplesortir une variable struct qui est à l'intérieur d'une carte non ordonnée

typedef struct dictionary{ 
std::string word; 
unsigned char hash[20]; 
std::string hex; 
} a_dictionary; 

typedef std::unordered_map<std::string, dictionary*> Mymap; 

std::unordered_map<std::string, dictionary* >::const_iterator got = c1.find(line); 
        if(out.is_open()) 
        { 
         if (got == c1.end()) 
         { 
         out << "????"; 
         } 
         else 
         { 
         out << got->first << " , "; 
         } 
        } 
       } 

Répondre

1

Le membre second du itérateur est votre pointeur vers la structure a_dictionary, donc il suffit d'y accéder comme vous le feriez avec un pointeur de structure normale:

out << got->first << " , " << got->second->word; 
Questions connexes