TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C++ Queue back() Function

C++ Queue back() Function with Examples on tutorial for beginners and professionals, constructor, emplace(), empty(), pop(), push(), back(), size(), top(), object and class, exception, static, structs, inheritance, aggregation etc.

<< Back to CPP

C++ Queue back() Function

C++ Queue function returns the value of the last element of the queue. Here last element is the one that is newest. The element which was most recently added is returned.

Syntax

value_type& back();
const value_type& back() const;

Parameters

The function does not take any parameters. It is only used to return the value of the last element.

Return value

The function returns the last element of the queue.

Example

#include <iostream>
#include <queue>
int main()
{
	std::queue<int> newqueue;
	newqueue.push(24);
	newqueue.push(80);
	newqueue.back () += newqueue.front();
	std::cout <<"newqueue.back() is modified to" << newqueue.back ();
	return 0;
}

Output:

newqueue.back() is modified to 104

Complexity

The complexity of the function is constant.

Data races

The function accesses the container. For returning the last element the whole queue container is accessed and then the value of the newest element is given.

Exception Safety

Guarantee as equivalent to the operations that are performed on the underlying container object is provided.

Next TopicC++ Queue




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf