1.

What is the difference between begin() and rbegin()?(a) both are the same(b) begin() returns an iterator to the first element and rbegin() returns an iterator to an element kept at the end of the vector(c) begin() returns an iterator to first element whereas rbegin() returns constant iterator to first element(d) begin() returns returns first element rbegin() returns voidI have been asked this question during a job interview.The origin of the question is seq_con Vector Class in section Class Hierarchies, Library & Containers of C++

Answer»

Right choice is (b) BEGIN() returns an iterator to the first ELEMENT and rbegin() returns an iterator to an element kept at the end of the VECTOR

The explanation is: begin() is USED to return the iterator to the first element of the vector whereas rbegin() is used to return the an element stored at in the LAST of a vector.



Discussion

No Comment Found

Related InterviewSolutions