String class, types of constructors, String operators in C++

String class is used in C++ to handle strings. A string class is consistent and easy way to handle strings. <string> header must be used for using string classes.

Constructors used in the string class:

Type-1: Empty string

string( );

Type-2: Creating a string object

string(const char *str);

Type-3: Creating string from another string.

string(const string &str);

Here are the string operators in C++:

String Operator Action
>> Input
<< Output
[ ] Subscript
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
== Equal
!= Not equal
+ Concatenation
= Assignment
+= Concatenation and assignment

Leave a Reply