# C++ - Set

## C++ Set

Set are one of the most common data types in C++. It is used for storing text. It can be created by enclosing characters in double quotation marks. It can be assigned to a variable using = sign.

set Myset = "Hello World!";


## Access character of a set

A character (also called element) of a set can be accessed with it's index number. In C++, index number starts with 0 in forward direction. The below figure and example describe the indexing concept of a set.

## C++ - Set Functions

### Capacity

FunctionsDescription
empty() Checks whether the set is empty or not.
size() Returns the length of the set in terms of bytes.
max_size() Returns the maximum length of the set.

### Iterators

FunctionsDescription
begin() Returns iterator pointing to the first element of the set.
end() Returns iterator pointing to the past-the-last element of the set.
rbegin() Returns reverse iterator to the last element of the set.
rend() Returns reverse iterator to the element preceding the first element of the set.
cbegin() Returns const_iterator pointing to the first element of the set.
cend() Returns const_iterator pointing to the past-the-last element of the set.
crbegin() Returns const_reverse_iterator to the last element of the set.
crend() Returns const_reverse_iterator to the element preceding the first element of the set.

### Modifiers

FunctionsDescription
clear() Clears all elements of the set.