Is it possible to restart a program from inside a program?

You can use a loop in your main function:

int main()
{
    while(!i_want_to_exit_now) {
        // code
    }
}

Or, if you want to actually restart the program, run it from a harness:

program "$@"
while [ $? -e 42 ]; do
    program "$@"
done

where 42 is a return code meaning "restart, please".

Then inside the program your restart function would look like this:

void restart() {
    std::exit(42);
}

If you really need to restart the whole program (i.e. to "close" and "open" again), the "proper" way would be to have a separate program with the sole purpose of restarting your main one. AFAIK a lot of applications with auto-update feature work this way. So when you need to restart your main program, you simply call the "restarter" one, and exit.