Voila je peux declarer une liste a l'exterieur de mon switch mais pas dedans ?
De meme pour afficher ma liste j'ai été obliger de le faire dans une fonction que j'appelle dans le switch sinon ca plante !!
Voici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
int main () {
  system("clear");
  int km;
  string im,m;
 
  list<Voiture> ls_veh;
  list<Voiture> la;
list declarée ici compile OK
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
int choix=menu();
  while (choix!=0)
    {
      switch (choix)
	{
	case 1 :
	  system("clear");	    
	case 2:
	  afficheListe(ls_veh);
	  list<Voiture> loi;
declarer une liste ici ca plante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
	  break;
	case 3 :
	  break;
 
	}
      choix=menu();
    }
  system("clear");
 
}
main.cc: In function `int main()':
main.cc:63: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:65: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:67: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:69: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:71: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:73: error: jump to case label
main.cc:61: error: crosses initialization of `std::list<Voiture, std::allocator<Voiture> > loi'
main.cc:63: warning: destructor needed for `loi'