Sign in to follow this  

error C2065: 'String' : undeclared identifier

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using MS Visual C++ 6.0 I'm want to use strings in my application, but I get the error: "error C2065: 'String' : undeclared identifier". I have string.h included in my application, but still is it moaning about the issue undeclared identifier. Can someone help me out please?

Share this post


Link to post
Share on other sites
string.h contains the C string functions (strcmp, strcat, etc.) The C++ string header is <string>, the string class is called std::string

Share this post


Link to post
Share on other sites
Now I get this error: "error C2653: 'std' : is not a class or namespace name"

What to include for this?

Share this post


Link to post
Share on other sites
And as Doggan pointed out you need to let the compiler know which namespace it is in. (Unless you using "using namespace std;" which is generally considered bad style.)

Share this post


Link to post
Share on other sites
Whenever I trying to place "using namespace std;" I says: "error C2871: 'std' : does not exist or is not a namespace"

Share this post


Link to post
Share on other sites
Quote:
Original post by Xeile
Now I get this error: "error C2653: 'std' : is not a class or namespace name"

What to include for this?

#include <string>

std::string myStringYay;

or...

#include <string>

using namespace std;

string myStringYay;

Share this post


Link to post
Share on other sites
Quote:
Original post by pi_equals_3
Quote:
Original post by Xeile
Now I get this error: "error C2653: 'std' : is not a class or namespace name"

What to include for this?

#include <string>

std::string myStringYay;

or...

#include <string>

using namespace std;

string myStringYay;


Thank you the first example worked.

Share this post


Link to post
Share on other sites
Sign in to follow this