Suite a ma question existentielle ici, je ne vois pas
pourquoi ceci en C++ ?
Example 65 Dangerous memory management
Que faire alors ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 String myFunc( const char* myArgument ) { String* temp = new String( myArgument ); return *temp; // temp is never deallocated and the user of myFunc // cannot deallocate because a temporary copy of // that instance is returned. }
Partager