?? front.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>front</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">C++ Vectors</a> > <a href="front.html">front</a> </div> <div class="name-format"> front </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <vector> <a href="../containers.html">TYPE</a>& front(); const <a href="../containers.html">TYPE</a>& front() const;</pre> <p>The front() function returns a reference to the first element of the vector, and runs in <a href="../complexity.html">constant time</a>.</p> <p>For example, the following code uses a vector and the <a href="../cppalgorithm/sort.html">sort() algorithm</a> to display the first word (in alphabetical order) entered by a user:</p> <pre class="example-code"> vector<string> words; string str; while( cin >> str ) words.push_back(str); sort( words.begin(), words.end() ); cout << "In alphabetical order, the first word is '" << words.front() << "'." << endl;</pre> <p>When provided with this input:</p> <pre class="example-code"> now is the time for all good men to come to the aid of their country</pre> <p>...the above code displays:</p> <pre class="example-code"> In alphabetical order, the first word is 'aid'.</pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="back.html">back</a><br> (C++ Lists) <a href="../cpplist/pop_front.html">pop_front</a><br> (C++ Lists) <a href="../cpplist/push_front.html">push_front</a> </div> </div> </td> </tr> </table></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -