Course Object Oriented Programming
Class String
Let's now look at a very useful and interesting class: the string.
What is it?
In C language, for us to have a string, we need to declare a vector of characters (char), which will have a predetermined size at its initialization. To perform operations with these vectors, we can then include the string.h library. See an example:
``cpp
#include <stdio.h>
#include <string.h>
int main() {
char s[10]; // Declaring a character vector with 10 spaces
strcpy(s, "Neps"); // Naming the vector "Neps".
printf("%s\n", s); // Printing the vector s
}
In C++ language, on the other hand, operations with *string*s are much easier, as the Standard Library provides us with the **string** class under the header of the same name, which includes several features. We can then include that library and instantiate an object of that class:
```cpp