C++ queue front() FunctionLast Updated : 17 Mar 2025 C++ Queue front() function returns the value of the front element of the queue. The first element is the oldest element or the element which was initially added to the queue. The function is used to return that element. SyntaxParametersThe function does not take any parameter, it is only used to return the value of the oldest element or the element at the front end of the queue. Return valueThe function returns the front element of the queue. Example 1Output: newqueue.front() is modified to 44 Example 2Output: 11 ComplexityThe complexity of the function is constant. Data racesThe function accesses the container. The queue container as a whole is accessed, and then the element which is the oldest is returned. Exception SafetyGuarantee as equivalent to the operations that are performed on the underlying container object is provided. Next TopicC++ Queue |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India