409Fermer411
squalylLe 19/01/2010 à 12:12
[google]singleton object[/google] ? c'est pas tout a fait ce concept mais presque:

En gros tu fais ton instance et tu la stockes dans un champ statique uniquement si ce champ vaut null.

en pseudo c++
class date {
private:
static date the_undefined_one = null;
};

date date::getUndefinedDate() {
if ( date::the_undefined_date == null) {
date::the_undefined_date = new date(komifo);
}
return date::the_undefined_date;
}