If by string you mean the string class, it's because they're dynamically allocated, have all the necessary search, modification, and segment accessing functions built in, and unless you do something quite stupid you'll never have any memory problems with them..
If by a character sequence, you mean a char *, then it is typically considered bad practice to use them at all in C++.
However, you sometimes need to use char *'s when interfacing with legacy code. In these cases, I recommend using strings for the bulk of the program, and then using the string::c_str() function to get a char * representation of the string. If the lagacy gives you a char *, pass it immediately into a string constructor. If you follow these rules, you should be pretty safe.
Maybe the OP means something like std::vector<char> when he says "character sequences". If I didn't really want a string, I'd rather store my data to an std::vector<char> because doing so saves me the cstr representation and the operations made on it every time I change my data.
Is it not pretty obvious that he means a char array over string objects? I'm also assuming that helios knew this and was just being picky about the use of terms, which has made you all overlook the obvious?
A string is a character sequence (much like every month has (at least) 28 days) but a character sequence isn't necessarily a string. In c++ you could say it like this:
1 2
class CharacterSequence {/*...*/};
class String: public CharacterSequence {/*...*/};
EDIT: A string is a character sequence that has some meaning in a linguistic context.
Ok, I'm not arguing anymore on this. We could do this all day and I can't afford it. Clearly, we have a different understanding of the meaning of the word "string".
Why don´t we take the global accredited meaning from a dictionay? We can derive the std::string´s meaning from it... Or just "ask" the creators of the stl how they came up with naming std::string std::string:P...
In mathematical logic, more precisely in the theory of formal languages, and in computer science, a string is a sequence of symbols that are chosen from a set or alphabet.
In computer programming, a string is, essentially, a sequence of characters. A string is generally understood as a data type storing a sequence of data values, usually bytes, in which elements usually stand for characters according to a character encoding, which differentiates it from the more general array data type. In this context, the terms binary string and byte string are used to suggest strings in which the stored data does not (necessarily) represent text.
In mathematical logic, more precisely in the theory of formal languages, and in computer science, a string is a sequence of symbols that are chosen from a set or alphabet.
In mathematical logic, more precisely in the theory of formal languages, and in computer science, a string is a sequence of symbols that are chosen from a setor alphabet.
You know that the character sets contain more than just the alphabet?!?!?...
r0shi wrote:
In computer programming, a string is, essentially, a sequence of characters. A string is generally understood as a data type storing a sequence of data values, usually bytes, in which elements usually stand for[b] characters according to a character encoding, which differentiates it from the more general array data type.[/b] In this context, the terms binary string and byte string are used to suggest strings in which the stored data does not (necessarily) represent text.
In computer programming, a string is, essentially, a sequence of characters. A string is generally understood as a data type storing a sequence of data values, usually bytes, in which elements usually stand for characters according to a character encoding, which differentiates it from the more general array data type. In this context, the terms binary string and byte string are used to suggest strings in which the stored data does not (necessarily) represent text.
Same as above... character does not only mean a-z and 1 to 0... It´s alsow a term for a symbol which includes any other characters in the set...
BTW:
Generally, string is a thin, flexible piece of rope or twine which is used to tie, bind, or hang other objects.