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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the role of C++ 's array". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the role of C++ 's array?"
Let's first take a look at how to use array.
To use array, you first need to include the header file in your code:
# include
Because array is a class in the standard library, you need to specify the namespace:
Using std:array
Or specify the namespace directly before array:
Std::array..
Let's take a look at how to define array objects. Go straight to the sample code.
# include
Using std::array
Int main () {
Std::array a1 {{1, 2, 3}}
Std::array a2 = {1,2,3}
Std::array A3 = {std::string ("a"), "b"}
}
From the above example, we can clearly see the difference between the definition of array and vector. When array is defined, you need to specify the size of the container and match the actual number of elements in the container. Others are basically the same as vector. Like vector, array also has some operations for element access, which is basically the same as vector, so put the sample code directly:
/ / array Demo
# include
# include
Using std::array
Int main ()
{
Array arr1 = {1,2,3,4}
Std::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.