Quote:Original post by Way Walker
I don't see a reason to not go with a global.
If you want some justification for not making it a singleton, just allow the user of the class to specify hich stream it should print to. This is useful and it's entirely possible you may want more than one Print object so you can print to multiple streams.
Really, "Singleton" is just a fancy name for "One and only one global instance". If everything needs access to a given instance of Print, that sounds like a job for a global. Why not make a global? Because down the line you may want different parts to print to different Print objects. Depending on exactly what you're printing, this may either be unlikely or the Print instance might easily and logically be grouped with other things you're passing around (e.g. as a member of some "world state" object).
However, I see no shame in using a global when it seems appropriate. Is the standard library poorly designed because std::cout is a global (or does tucking it in a namespace make it "less global"?)?
those are very powerful thoughts you put into words there.
I guess it was appropriate to use a global in that case.
But it seems like I've already implemented singleton, and I think I'm going to adventure and practice using singleton using this opportunity.
Valid Point!