Question concernant les static
Bonjour, j'aurais une question concernant les statics.
Supposons le code suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void MyFrame::OpenFile(wxCommandEvent &event) {
static wxString filter = wxT("Modèle MAGiC (*.magic)|*.magic");
static wxString title = wxT("Choissisez un fichier");
static wxString defaultDir = C_DEFAULT_DIR;
static wxString defaultFilename = wxEmptyString;
wxFileDialog dialog(this, title, defaultDir, defaultFilename, filter, wxOPEN);
if (dialog.ShowModal() == wxID_OK) {
std::string path = dialog.GetPath().mb_str();
readFile(path);
SetStatusText(wxT("Fichier en cours: " + path));
}
} |
Cette une fonction qui est appelée dans un OpenFile Dialog lorsque l'utilisateur ouvre un fichier. Puisque le filter, title, defaultDir, defaultFilename n'ont pas vraiment à être initialisé à chaque ouverture de fichier, est-il pertinent de les mettre static? Quelques avantages apparents? Merci!