OP complained about the compilation problem, and putting the block around object construction and usage code is a solution; everything further is speculation without looking into the rest of the code. Still, it's pretty much obvious that this piece of code is driven by user input on terminal, so it's certainly going to take *way* longer time for user to type in these values each time (and to corresponding iostream routines to parse corresponding numbers out of them) than for machine to construct/destruct these objects.
Alike - without looking into the rest of the code, one could say the piece of code you provided later is rather inefficient - why would you create three different solver objects if you're going to use only one? This is exactly what OP mentioned above he want to avoid.
As for design patterns: there is a time aspiring
C++ programmer should learn about them, and situations when they should be put into use, but in this particular case there is nothing intrinsically wrong with using switch statement and construct objects in the way above, and in any case one should learn the basics first - at this moment, OP would probably benefit more from mentioning that
one shouldn't put "using namespace std" in his code, than from all this highly speculative what-if talk.