Hello!
Does anyone know of a way to call (or create) a variable by using the *contents* of another variable, presumably a concatenated string?
An attempt I didn't expect to work is below to clarify...if it clarifies.
Does what I'm asking make sense? Is there a way to do it?Code:#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { const char a='B'; const int B=99; const char* A=a; int ending; cout << a << ": Should read 'B'" << endl; cout << B << ": Should read '99'" << endl; cout << A << ": Should read 'B'" << endl; cout << *A << ": Should read 'B'" << endl; cout << &A << ": Should read some memory address crap" << endl; //cout << *a << endl; cout << "Press enter to end program" endl; cin >> ending system("PAUSE"); return EXIT_SUCCESS; }
Thanks muchly!



LinkBack URL
About LinkBacks


