bonjour,
je narrive pas a savoir pk mon prog plan avec plein de message d'erreur sur les pair map , alors ke je veux tt simplement faire une list de pair contenant un string et un arbre

Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ifndef ENV_HH                                                                                                                                                                                                   # define ENV_HH                                                                                                                                                                                                  #include <string>                                                                                                                                                                                                #include <list>                                                                                                                                                                                                  
#include <map>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
template <class T>                                                                                                                                                                                               
class Env                                                                                                                                                                                                        
{                                                                                                                                                                                                                
  public:                                                                                                                                                                                                        
    //------------------------------                                                                                                                                                                             
    //constructeur/destructeur:                                                                                                                                                                                  
    //------------------------------                                                                                                                                                                             
    Env(){}                                                                                                                                                                                                      
    virtual ~Env(){};                                                                                                                                                                                            
 
    //------------------------------                                                                                                                                                                             
    //Fonctions:                                                                                                                                                                                                 
    //------------------------------                                                                                                                                                                             
    void add_list (std::string s, T& t)                                                                                                                                                                          
    {                                                                                                                                                                                                            
      typename std::map<std::string, T>::iterator i;                                                                                                                                                             
      if (l.begin() == l.end())                                                                                                                                                                                  
        l.push_back(std::pair<std::string, T> (s, t));                                                                                                                                                           
      else                                                                                                                                                                                                       
      {                                                                                                                                                                                                          
        m.insert(l.begin(), l.end());                                                                                                                                                                            
        for (i = m.begin(); i != m.end(); i++)                                                                                                                                                                   
          if (i->first == s)                                                                                                                                                                                     
            i->second = t;                                                                                                                                                                                       
          else                                                                                                                                                                                                   
            l.push_back(std::map<std::string, T> (s, t));                                                                                                                                                        
      }                                                                                                                                                                                                          
    }                                                                                                                                                                                                            
 
    int search_list(std::string s)                                                                                                                                                                               
    {                                                                                                                                                                                                            
      if (l.begin() == l.end() &&  l.begin()->first == s)                                                                                                                                                        
        return (l.begin()->second->value ());                                                                                                                                                                    
      else                                                                                                                                                                                                       
      {                                                                                                                                                                                                          
        m.insert(l.begin(), l.end());                                                                                                                                                                            
        typename std::map<std::string, T>::iterator i = m.begin();                                                                                                                                               
        for ( ; i != m.end(); i++)                                                                                                                                                                               
          if (i->first == s)                                                                                                                                                                                     
            return (i->second->value ());                                                                                                                                                                        
        return (1);                                                                                                                                                                                              
      }                                                                                                                                                                                                          
    }                
 
  protected:                                                                                                                                                                                                     
    //------------------------------                                                                                                                                                                             
    //Variables:                                                                                                                                                                                                 
    //------------------------------                                                                                                                                                                             
    std::list<std::pair<std::string, T> > l;                                                                                                                                                                     
    std::map<std::string, T> m;                                                                                                                                                                                  
 
};                                                                                                                                                                                                               
 
//#include "Env.hxx"                                                                                                                                                                                             
 
#endif
[Balise CODE ajouté par mongaulois]