brewtarget-devs team mailing list archive
-
brewtarget-devs team
-
Mailing list archive
-
Message #00084
Re: cmake and a subdir
>
>
> Another thought. I need a pointer to an object that must be instantiated
> early, and is available to both the database class, and the options class.
> I think, but still don't know for sure, that you create a single instance,
> and then use that instance for the life of the application. So, I can't put
> it in Database, as that creates a new instance each time. Ideas?
>
The database is a singleton. If the object really has to do with the
database, you can put it there and initialize it in the constructor. If it
doesn't belong, maybe creating your own singleton class for the object is
an option.
http://en.wikipedia.org/wiki/Singleton_pattern
References