error C2065: 'String' : undeclared identifier

Started by
6 comments, last by Xeile 19 years, 6 months ago
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?
Advertisement
std::string StringName;
string.h contains the C string functions (strcmp, strcat, etc.) The C++ string header is <string>, the string class is called std::string
Now I get this error: "error C2653: 'std' : is not a class or namespace name"

What to include for this?
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.)
If a plant cannot live according to its nature, it dies; so a man.
Whenever I trying to place "using namespace std;" I says: "error C2871: 'std' : does not exist or is not a namespace"
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;
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.

This topic is closed to new replies.

Advertisement