Where are strings?
I can include all 3 of the following headers:
Yet declarations of
and
both get rejected by the compiler, stating that, "string is used as a type, but is not defined as a type." when in a class, and "string undeclared (first use this function)" elsewhere. I'm using Xcode 1.2 (OSX 10.3.9). What should I do?
Code:
#include <string>
#include <string.h>
#include <cstring>Yet declarations of
Code:
String j;and
Code:
string j;both get rejected by the compiler, stating that, "string is used as a type, but is not defined as a type." when in a class, and "string undeclared (first use this function)" elsewhere. I'm using Xcode 1.2 (OSX 10.3.9). What should I do?
Code:
#include <string>
std::string s;Also possible:
Code:
#include <string>
using std::string;
string s;Also possible, but not recommended:
Code:
#include <string>
using namespace std;
string s;
To clarify: all of the STL is in the std:: namespace. Hence, you have to specify that you want std::string (which is the proper name) in any of the three ways mentioned above. Some compilers pull in the std:: namespace silently, but it's wrong and dangerous.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| generate MD5 strings with Objective-C? | fernandovalente | 3 | 3,634 |
Jan 27, 2010 09:29 AM Last Post: Hog |
|
| C strings | mikey | 24 | 7,644 |
May 18, 2009 04:52 AM Last Post: Oddity007 |
|
| Converting integer/numeric values to Strings | vnvrymdreglage | 5 | 3,194 |
Oct 23, 2006 07:18 PM Last Post: vnvrymdreglage |
|
| Converting strings to functions | Joseph Duchesne | 10 | 4,997 |
Feb 23, 2005 11:42 PM Last Post: Skorche |
|

