Sign in to follow this  
Xeile

error C2065: 'String' : undeclared identifier

Recommended Posts

Xeile    256
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
twanvl    512
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
Woodsman    426
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
Xeile    256
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
pi_equals_3    517
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
Xeile    256
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this