I've been wondering how to pass argument to a singleton contructor. I already know how to do a singleton, but I've been unlucky to find a way to do it.
Here is my code (part of it).
Questionnary* Questionnary::getInstance(){
static Questionnary *questionnary = NULL;
if(questionnary == NULL){
cout << "Object created";
questionnary = new Questionnary();
}
else if(questionnary != NULL){
cout << "Object exist";
}
return questionnary;
}
Questionnary::Questionnary(){
cout << "I am an object";
}
//This is want i want to acheive
Questionnary::Questionnary(string name){
cout << "My name is << name;
}
Many thanks in advance
(BTW i know how and why a singleton is bad)