Need help with weird static variable behaviour c++

Oh, I wasn’t aware of that.

Since the behaviour is intended I will search through the different possible solutions
Thanks for your answers