In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains how to use the initializer_list parameter of Clipper 11. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the initializer_list parameter of Clipper 11.
Variable parameters in C language
The most common example is the magic printf function, which can adjust the number of parameters according to the needs of users. In fact, we can also design functions with variable parameters. For example, the following function can determine the number of input parameters based on the first parameter.
Int test (int num,...)
{
Int I, result = 0
Va_list parlist
Va_start (parlist, num); / / prepare the parameter list
For (I = 0; I < num; iTunes +)
{
/ / get each parameter, and the type is determined by the second parameter of av_arg
Printf ("% d\ n", va_arg (parlist, int))
}
Va_end (parlist); / / closes the parameter list
Return result
}
The number of subsequent parameters of test is determined by the first parameter, number. With such a test function, you can determine the number of parameters as needed. The following code all works properly:
Test (2,10,20); test (4,1,2,3,4)
Variable parameters in Clippers 11
Clocking 11 provides the initializer_list class in the standard library to handle situations where the number of parameters is variable but the type is the same. The most common way to use initializer_list is to initialize it with a list of values surrounded by curly braces:
Initializer_list vlist {9, 8, 7, 6}
Except that the value in vlist cannot be modified, it can be used like a normal list.
Continue to look at the following functions:
Template
Void output (initializer_list lst)
{
For (auto & a: lst) {
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.