Javatpoint Logo
Javatpoint Logo

C++ Vector cend()

This function is used to point to the past-the-last element (element after the last element) in the vector.

cend() vs end()

The cend() function returns the constant iterator while end() function returns an iterator. The element pointed by the end() functioncan be modified but not by the cend() function.


Consider a vector 'v', Syntax would be:


It does not contain any parameter.

Return value

It returns a constant iterator pointing to thepast-the-last element in the vector.

Example 1

Let's see a simple example.



In this example, cend() function is accessed using an object of constant iterator type.

Example 2

Let's see a simple example.


1 2 3 4 5
Next TopicC++ Vector

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA