|
-
Sep 20th, 2005, 04:47 PM
#1
Thread Starter
Frenzied Member
[C++] String class...Can't find it
I've tried everything to get a string working. I can't seem to find ANY helpful information on the compiler or classes you can use.
I've tried the following:
#include <string>
#include <string.h>
#include <String>
#include <String.h>
None of those work when I try to declare a String:
String s;
It gives me an error saying String is undeclared.
I'm using the Bloodshed IDE by the way, and I looked at an example it came with and they used:
#include <string.h>
but that still doesn't work for me.
Am I doing something wrong? Is there any helpful documentation?
-
Sep 20th, 2005, 04:50 PM
#2
Re: [C++] String class...Can't find it
The C++ string class lives in the std namespace, you can use it with:
Code:
#include <string>
std::string my_string = "this is a string";
or:
Code:
#include <string>
using namespace std;
string my_string = "this is a string";
-
Sep 20th, 2005, 04:53 PM
#3
Thread Starter
Frenzied Member
Re: [C++] String class...Can't find it
Thanks! That worked perfectly. I commented out using namespace std, so that was part of the reason I couldn't get it to work.
One more thing if you don't mind. I've got a really old book that I like to read(it's called Mastering C++ for pascal and c programmers), and it was using a capital S for string. Has this changed in the newer version of C++?
-
Sep 21st, 2005, 04:51 AM
#4
Re: [C++] String class...Can't find it
There never was a (standard) String class with a capital S. Maybe that book uses its own string class, or a speficic library.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|