title: C++ executing a code from a text file
body: <p>The title says it all. Like a compiler but not the same. I want a certain part of the code to be executed from an outer source in C++. And I don't know if that is even possible as it is in Javascript, Python etc.</p>
  
  <p>Let's say I got a text file titled sample.txt like this:</p>
  
  <pre><code>int a = 10, c;
  cin &gt;&gt; c;
  cout &lt;&lt; a + c;
  </code></pre>
  
  <p>And I'll call the text file in main() function and compiled the .exe file. When I run it, is it possible for it behave dynamically as if the code from the file is embedded in there and write 10 + input? The source file should be changed and different results will apply next time it runs. It's just an example piece of code by the way, I might want to run some for/while loops and if conditions etc. </p>
  
  <p>PS: I know how to read from file and assign it as an integer or write it on the screen, that's not what I want. I need functions to be compiled through. Thanks.</p>