This is done by having multiple surfaces, often called "states", such as main menu, options, game.
One possibility is to have an abstract base class State and derived classes MainMenu, Options, Game for a concrete state. When clicking a button, the state is changed (either by creating a new state object and possibly destroying the old one, or just changing a pointer).