i need a way to restart my console application. I don't think a do-while loop can help me, because the restart should happen in the middle of the code, if a condition isn't achieved after several attempts. Also if the program is restarted, all instances of classes should be removed.
Move the code for the running loop into a separate function from main. When you want to "restart" you return from your running loop and allow main to evaluate the returned value to determine if it should call into that function again or exit. RAII takes care of the rest.