delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/02/14:32:46

Mime-Version: 1.0
X-Sender: johnmeyer_1978 AT pop DOT mail DOT yahoo DOT com
Message-Id: <a04310101b50d3df1a54e@[158.142.75.70]>
In-Reply-To: <eeLF4.13555$K9.107792@typhoon.nyroc.rr.com>
References: <eeLF4.13555$K9 DOT 107792 AT typhoon DOT nyroc DOT rr DOT com>
Date: Sun, 2 Apr 2000 11:14:40 -0700
To: djgpp AT delorie DOT com
From: John Meyer <john_meyer AT geocities DOT com>
Subject: Re: classes
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019