Google Interview Question

Can you explain how you would implement a thread-safe singleton pattern in C++?

Interview Answer

Anonymous

May 1, 2024

I’d probably just create a static instance of the singleton in the getInstance() function. That way, the instance is only created once and then returned whenever it’s needed. I don't think we need to worry much about threading issues because static variables are supposed to handle it.