Is there a way to input the name of a string and return the value of an integer that has the same name as the string? For example, suppose I have this program...
Code:
#include <iostream>
using namespace std;
int main(){
string nameofstring = "test";
int test = 1;
cout << nameofstring; //outputs the word "test", I would like it to output the integer 1. How do I do this?
cin.get();
return 0;
}
I would like it to read the name of the string and find the return the integer of the same name as the string. I think it can be done in Java using getInteger( String nm, int val ). Is this possible in C++? Thanks.