Arduino programs are written in C++. C++ is a "compiled" language - the compiler runs on your computer and turns the program source code into a machine code binary that's then copied to the flash memory on the ESP32 and executed there.
MicroPython (Python) and Espruino (Javascript) are both interpreted languages. The interpreter is a program written in C or C++, compiled, and then copied to flash memory on the ESP32. It's the interpreter that reads the strings that represent the program and then executes them. That's why MicroPython and Espruino both are able to execute a script loaded externally.
Arduino programs can't do this, at least not for C or C++ programs, because the C or C++ compiler would have to run on the ESP32, and then the binary code would have to be linked against the code already running on the ESP32. This is all quite a bit beyond the capabilities of the CPU and the Arduino framework (and ESP-IDF, which it's built using).
So you're not going to have your C++ program that runs on an ESP32 load and compile another C++ program, execute it, and use its return value.
What you can do is use an embedded interpreter for another language to interpreter and execute code in that language. You could even write your own if you want.
These interpreters will only be suitable for running small, simple programs. If you want to do anything more then you're best off sticking with MicroPython, CircuitPython or Espruino, which I understand you said you can't do, but that's your only choice in this area.
You can find examples of embedded interpreters by searching the web for "esp32 embedded interpreter". The languages Forth, Lua and even BASIC may work. There is also an "embedded C interpreter" called "picoc", which will be limited compared to true C but might do what you need.