• Advertisement
Sign in to follow this  

string class (C++)

This topic is 4224 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 was wondering what "managed" string classes are generally being used by C++ programmers. Right now I'm using a homemade one, but I figured there are probably much better ones out there. I need one that works at least on windows, linux and mac.

Share this post


Link to post
Share on other sites
Advertisement
In the standard library there is a string class.

example


#include <string>
using namespace std;

string first_name = "Bjarne";
string last_name;

last_name = "Stroustrup";

string names = first_name + " " + last_name;
cout << names << endl;

names = last_name + ", " + first_name;
cout << names << endl;




There is lots of nice stuff beside the string class in the c++ standard library. Like managed dynamic arrays<vector>, linked list <list>. It's worth checking out.

Share this post


Link to post
Share on other sites
Standard C++ contains std::string. You can use it by including <string>.

There are more of these precious jewels: dynamic arrays, linked lists, sorting algorithms. See for example cppreference.com and a gazillion other sites. These things make your life better [wink].

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
std::string

Share this post


Link to post
Share on other sites
ok thanks std::string it will be then.

I really should use the standard C++ librabry more often, it would probably save me alot of time :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ronkfist
ok thanks std::string it will be then.

I really should use the standard C++ librabry more often, it would probably save me alot of time :)


That, and it would prevent having various gamedevers yelling 'std::string' at you. That'd sound just weird being pronounced at all, let alone yelled.

Share this post


Link to post
Share on other sites
Quote:
Original post by joanusdmentia
That, and it would prevent having various gamedevers yelling 'std::string' at you. That'd sound just weird being pronounced at all, let alone yelled.

I pronounce it "standard string." Hardly weird.

Share this post


Link to post
Share on other sites
Quote:
Original post by ronkfist
ok thanks std::string it will be then.

I really should use the standard C++ librabry more often, it would probably save me alot of time :)


Well, it *is*, you know, *the standard library of the language you're using*. Would you ignore it if you were using any other language?

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
Original post by ronkfist
ok thanks std::string it will be then.

I really should use the standard C++ librabry more often, it would probably save me alot of time :)


Well, it *is*, you know, *the standard library of the language you're using*. Would you ignore it if you were using any other language?


Not really, it just doesn't feel the same way as it does in java or .NET for example, so I never really saw it as a part of C++. I actually have old C++ books where the std library isnt even mentioned.
The std library might feel natural for ppl who are used to only C++ or come from C, but coming from Java im used to its conventions such as camelCasing, so the std library doesn't really fit into that, I find it plain ugly.

Share this post


Link to post
Share on other sites
Naming conventions have more to do with the language and the "culture" of programmers that use it than with the library. (Although the standard library does often influence the culture.) That said, C++ is in a unique position of being ubiquitous and yet generally spectacularly poorly taught. x.x

Share this post


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

  • Advertisement