المتغيرات
فضاءات التسمية
أفعال

std::{{{1}}}::back

من cppreference.com
reference back();
قالب:mark since none
const_reference back() const;
قالب:mark since none

Returns reference to the last element in the container.

Calling ‎back‎ on an empty container is undefined.

محتويات

[تعديل] Parameters

(none)

[تعديل] Return value

Reference to the last element.

[تعديل] Complexity

Constant.

[تعديل] Notes

For a container ‎c‎, the expression return c.back(); is equivalent to { auto tmp = c.end(); --tmp; return *tmp; }

[تعديل] Example

The following code uses ‎back‎ to display the last element of a std::{{{1}}}<char>:

#include <{{{1}}}>
#include <iostream>
 
int main()
{
    std::{{{1}}}<char> letters {'o', 'm', 'g', 'w', 't', 'f'};
    if (!letters.empty()) {
        std::cout << "The last character is: " << letters.back() << '\n';
    }  
}

الخرج:

The last character is f

[تعديل] See also

قالب:dsc mem fun