Bonjour à tous,
J'ai un warning dans une classe qui me pose problème, puisque j'ai un bug à l'exécution sur ce même endroit...
warning C4172: retourne l'adresse d'une variable locale ou temporaireMon code plante ici :
Code : 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 class DisplayManager { public: typedef std::set<wxMDIChildFrame*> ArrayOfFrame; static void closeAll(); static wxMDIParentFrame *frame_parent; static int find(wxMDIChildFrame*); static int size(); static bool del(int i); static bool del(wxMDIChildFrame *frame); static void insert(wxMDIChildFrame *frame); static bool erase(wxMDIChildFrame *frame); static void clear(); static ArrayOfFrame & getArray() {return array_frame;} static ArrayOfFrame::iterator & begin() {return array_frame.begin();} static ArrayOfFrame::iterator & end() {return array_frame.end();} // OK static wxMDIChildFrame* at(int); protected: static ArrayOfFrame array_frame; };
Il se trouve que si je ne renvoi pas une référence, mais une copie avec:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 void ImageFrameCamera::stopAllFilm() { is_film = false; DisplayManager::ArrayOfFrame::iterator it; for(it = DisplayManager::begin(); it != DisplayManager::end(); it++) // PLANTE ICI { // } }
ça marche...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 static ArrayOfFrame::iterator begin() {return array_frame.begin();} // warning ici static ArrayOfFrame::iterator end() {return array_frame.end();} //
Une explication docteur ?![]()
Partager