 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael J. Reeves, AA, AS Guest
|
Posted: Tue Oct 28, 2003 2:09 am Post subject: Strings VS. char... |
|
|
I am trying to write a program using string's and/or char's...
When I declare a string identifier, I am getting an error
indicating that this is an out-of-date method of declaring:
string firstName, lastName;
What is wrong with this declaration???
TIA.
(REMOVE "NoSPAM." from REPLY address to reply)
(This email scanned by Norton Anti-Virus and Certified VIRUS FREE!)
Michael J. Reeves, AA, ASc
E-Mail: [email]michaeljreeves (AT) comcast (DOT) net[/email]
---------------------------------------------------------
I have no SPAM. I don't give a SPAM.
I take no SPAM from anyone. I am NOT in the SPAM business!!!
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Josephine Schafer Guest
|
Posted: Tue Oct 28, 2003 5:28 am Post subject: Re: Strings VS. char... |
|
|
"Michael J. Reeves, AA, ASc" <michaeljreeves (AT) comcast (DOT) net> wrote
| Quote: | I am trying to write a program using string's and/or char's...
When I declare a string identifier, I am getting an error
indicating that this is an out-of-date method of declaring:
string firstName, lastName;
|
Well it's std::string.
Try this -
#include <string>
std::string firstName, lastName;
HTH,
J.Schafer
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Richard Smith Guest
|
Posted: Tue Oct 28, 2003 3:51 pm Post subject: Re: Strings VS. char... |
|
|
Michael J. Reeves, AA, ASc wrote:
| Quote: |
When I declare a string identifier, I am getting an error
indicating that this is an out-of-date method of declaring:
string firstName, lastName;
What is wrong with this declaration???
|
That depends what else you've got in the file. I'm assuming
you've remember to include the standard string header:
#include <string> // Note: not <string.h> which is
// something completely different.
Also, unless you've got a very old compiler / standard
library, the string type will be in namespace std. There
are several ways to access this. One possibility is to
fully qualify the string identifier:
std::string firstName, lastName;
Another possibility is to put a using directive somewhere
above the use of string:
using namespace std;
--
Richard Smith
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|