Creating an Object
Simplest solution is creating an instance of the object.
Above solution works. However
l2 is a new instance of
Singleton solution using a global variable
Above solution works. However this solution relies on creating a global variable. To the extent possible it is best to avoid polluting global namespace.
Single solution without polluting global namespace
This solution does not pollute global namespace.