Mail Archives: djgpp/2000/04/02/14:32:46
>I'm new to classes, Is the anyway that I would be able to do this?
>
>class myClass
>{
> // there would be things here
>};
>
>int main(void)
>{
> char stuff[20];
> cin>>stuff;
> myClass stuff; // I want to name it the string
> // stored in stuff not the word stuff
>return 0;
>}
>thanks
Nope, not that I know of. Variable names are precompiled into the
program. Besides which, you have already declared a variable with
the name "stuff", so C++ will generate an error.
What you are probably looking for is a map, where you can refer to
variables using entered data. Those are way down the line, though,
although you can look up the STL if you want.
- Raw text -