C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strings VS. char...

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Michael J. Reeves, AA, AS
Guest





PostPosted: Tue Oct 28, 2003 2:09 am    Post subject: Strings VS. char... Reply with 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;

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





PostPosted: Tue Oct 28, 2003 5:28 am    Post subject: Re: Strings VS. char... Reply with quote




"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





PostPosted: Tue Oct 28, 2003 3:51 pm    Post subject: Re: Strings VS. char... Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.