
Patrick B. answered 07/30/19
Math and computer tutor/teacher
Yes, it will output "bar" because all the constructor does is return a pointer to the existing instance.
Now, as an example of why such a design, I will share my experience with you, about the objects of an ATM machine that requires singleton classes. The vast majority of such singletons are device objects such as the printer, modem, display, pinpad, keyboard, swiper, and bill dispenser.
First of all, these device objects open up a communications serial port so that the terminal can communicate with the device. Once the communications channel is open, it cannot be opened again. There is one and only one serial port and the device is using it. Therefore it does not make sense to have multiple instances of the object. All there is a GLOBAL instance of the device that gets passed around to whatever process needs the device.
In general, the same can be said about other peripheral devices: security cameras, signature captures, fingerprinting, forensic equipment, medical equipment etc. which are typically found in embedded environments.
It is an uncommon , but not an earth shaking concept