GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::vector::back(3) C++ Standard Libary std::vector::back(3)

std::vector::back - std::vector::back


reference back(); (until C++20)
constexpr reference back(); (since C++20)
const_reference back() const; (until C++20)
constexpr const_reference back() const; (since C++20)


Returns a reference to the last element in the container.


Calling back on an empty container causes undefined behavior.


(none)


Reference to the last element.


Constant.


For a non-empty container c, the expression c.back() is equivalent to
*std::prev(c.end())


The following code uses back to display the last element of a std::vector<char>:

// Run this code


#include <vector>
#include <iostream>


int main()
{
std::vector<char> letters {'a', 'b', 'c', 'd', 'e', 'f'};


if (!letters.empty()) {
std::cout << "The last character is '" << letters.back() << "'.\n";
}
}


The last character is 'f'.


front access the first element
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.