#943 – Lazy Instantiation, Solution #1

There are cases when we have a large amount of data to allocate in a class, either in an instance of the class or as static data. We want to allocate and initialize the data as late as possible, i.e. just before we need to use the data. This is know as lazy instantiation.

One method for lazy instantiation is to check to see if the data is instantiated, wherever we try to use it.