CPP MCQ
What is the difference between begin() and cbegin() in vectors?
A)
both are same
B)
begin() returns returns first element cbegin() returns void
C)
begin() returns iterator to first element and cbegin() returns iterator to last element
D)
begin() returns an iterator to first element whereas cbegin() returns constant iterator to first element

Correct Answer : Option (D) :   begin() returns an iterator to first element whereas cbegin() returns constant iterator to first element

Explanation : Both begin() and cbegin() are used to access the first element of the vector. The function begin() returns an iterator to first element whereas cbegin() returns a constant iterator to first element.