I'm trying to use a string as a variable name but I don't know how.
For example, str declared as a string and gets the value of "number" and I wanted to use the value of the str to be the variable name of an integer type.
Just to through around some useful terminology, a map is an associative container. I'm assuming that the OP has the intention of associating a string with a variable.
I'm doing a simple C++ interpreter and I'm having problems if the cpp file declared a variable and used it in the succeeding lines. Any way around to resolve this?
Either an associative container from the STL or an object you made yourself could work. I personally recommend one you make yourself for interpreting a language like C++.
A C++ compiler/interpreter is one of the most complex language programs you can choose to write. I suggest you work with a very small subset of the language...
The generic structure of the C language is good to start with (implement control structures, functions, structs, some preprocessor directives, but nothing significantly more advanced). Once you do that, start implementing exception handling, then slowly objects, then templates, and so on.