[try Beta version]
Not logged in

 
Singletons

Feb 15, 2016 at 7:29pm
I'm messing just now learning about singletons and was wondering if it is at all possible to change your singleton at all? For example I created a date Singleton and I know I can only have one constructor controlling it but is it possible to change it later on? Here's what my main file looks like.
1
2
3
4
5
6
7
8
9
10
int main()
{
  Date *date1 = Date::instance(3, 2014, "March");

  date1->print();
  date1 = Date::instance(5, 2014, "May");
  date1->print();

  return 0;
}


which works just fine but I've tried everything I can to be able to change the values later on and can't figure out how to do it. I understand Singletons are made so you don't have multiple constructors but is it possible to change its values at all later on?
Feb 15, 2016 at 8:27pm
You change the values like any other class. Show us how you tried to do it that didn't work.
Topic archived. No new replies allowed.