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

std::{{{1}}}::front

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

Returns a reference to the first element in the container.

Calling ‎front‎ on an empty container is undefined.

محتويات

[تعديل] Parameters

(none)

[تعديل] Return value

reference to the first element

[تعديل] Complexity

Constant

[تعديل] Notes

For a container ‎c‎, the expression c.front() is equivalent to *c.begin().

[تعديل] Example

The following code uses ‎front‎ to display the first 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 first character is: " << letters.front() << '\n';
    }  
}

الخرج:

The first character is o

See also

قالب:dsc mem fun