TheDeveloperBlog.com

Home | Contact Us

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

C++ Vector pop_back() function

C++ Vector pop_back() function tutorial for beginners and professionals with examples on assign(), at(), back(), begin(), capacity(), cbegin(), cend(), clear(), crbegin(), crend(), data(), emplace(), end(), front(), rbegin(), resize(), size(), swap() etc.

<< Back to CPP

C++ Vector pop_back()

It deletes the last element and reduces the size of the vector by one.

Syntax

Consider a vector v.Syntax would be:

v.pop_back();

Parameter

It does not contain any parameter.

Return value

It does not return any value.

The following illustration show how pop_back() function works :


cpp Vector pop_back()

This illustration shows how last element of the vector is deleted using pop_back() function.

Example

Let's see a simple example.

#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<string> v{"welcome","to","javaTpoint","tutorial"};
cout<<"Initial string is :";
for(inti=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<'\n';
cout<<"After deleting last string, string is :";
v.pop_back();
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
return 0;
}

Output:

Initial string is :welcome to javaTpoint tutorial 
After deleting last string, string is :welcome to javaTpoint

In this example, last string is being removed using pop_back() function.

Next TopicC++ Vector




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