In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What is the use of vector container begin () and end () function, front () and back () in C++STL? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Vector container (vector) is a sequential container, which is a continuously allocated memory and supports random access. From the point of view of data arrangement, it is very similar to an array. The difference between an array and vector is that an array is a statically allocated space. Once the size of the space is allocated, it cannot be changed. For example, int a [6] While vector allocates memory dynamically, with the continuous insertion of elements, it will continue to expand its capacity according to its own set of mechanisms. The capacity growth of vector containers is double the current capacity of containers.
Begin function:
Function prototype:
Iterator begin ()
Const_iterator begin ()
Features:
Returns an iterator of the starting element in the current vector container.
End function:
Function prototype:
Iterator end ()
Const_iterator end ()
Features:
Returns an iterator for the last element in the current vector container.
Front function:
Function prototype:
Reference front ()
Const_reference front ()
Features:
Returns a reference to the starting element in the current vector container.
Back function:
Function prototype:
Reference back ()
Const_reference back ()
Features:
Returns a reference to the last element in the current vector container.
Example:
# include
# include
Using namespace std
Int main ()
{
Vector v1
Vector::iterator iter1
Vector::iterator iter2
V1.push_back ('m')
V1.push_back ('n')
V1.push_back ('o')
V1.push_back ('p')
Cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.