The clear() method is used to delete all the elements from a deque container. It takes no parameters and has a void return type. This method is an inbuilt function in the library of C++.
Example 1:
deque myDeque {1, 2, 3, 4, 5}; myDeque.clear(); // deletes all elements of deque
Example 2:
deque myWords {"Hello", "World", "Welcome"}; myWords.clear(); // deletes all elements of deque
In both the examples, the clear() method is used to delete all the elements of the deque object myDeque and myWords respectively.
Package library:
C++ (Cpp) deque::clear - 30 examples found. These are the top rated real world C++ (Cpp) examples of deque::clear from package zpugcc extracted from open source projects. You can rate examples to help us improve the quality of examples.