If I'm reading your question correctly, you want to be able to do something like this:
Text File:
Source File:
Code:
#include <iostream>
#include <fstream>
int main()
{
/* read in data from file */
std::cout << var1 + var2 << std::endl;
return 0;
}
If that's the case, then no, that's not going to work. The variables need to be named at compilation time, not execution time.
What I'd suggest is that you make a class that emulates a symbol table (i.e. holds variable names and addresses) for your data file.
You would initialize a SymbolTable by having it read your data file and store the names of the variables along with their line number ("address"

. You might also want it to store a value for each variable, too, so you don't have to keep looking back at the data file to get it.
You could then have code that works like this:
Text File:
Source File:
Code:
#include <iostream>
#include <fstream>
#include "symbtab.h" // for symbol table
int main()
{
ifstream fin( "datafile.txt" );
SymbolTable st( fin ); // read in data
std::cout << st.get( "var1" ) + // get data
st.get( "var2" ) // ditto
<< std::endl;
return 0;
}
If any changes are made to the variables during the program, you could change them immediately, wait until a "save" command is called, or wait until your symbol table is being destroyed to write the data to the file. I suppose it depends on what you're doing and how often these changes will be made.
There are obviously better and easier ways to implement the class, but this was just to make it look as much like what you're trying to do as possible. If you get the general idea and this is something like what you need, you'll probably want to modify it to something that's easier to make.
If, on the other hand, I didn't understand your question correctly, then I've wasted enough of your time without really helping, so I'll just stop now.