If our program is:
and the person inputs
cout << "Print out next instruction: " ;
cin >> instruction;
into the variable instruction at runtime, is there
any way to make the program interpret this as actual
source code and make it edit its own source code?
In which case it would literally print out "hello" in the next
line of the console?
Something like reflective programming?
No way in C++. It has to be compiled and linked first etc. You have to write an interpreter for this, but this will probably be too much work for such a task. Reflective programming is not for C++.
You can test the instruction and then use if-else branches to determine what to do now, which would be the best way.
Please note that this type of programming is highly unsafe and should not be used in general, except if the implementation is secured.