C ++ STL中的数组get()函数?
在本节中,我们将看到get()C++STL中的数组功能。此函数用于获取数组容器的第ith个元素。语法如下-
语法
get<i> array_name
此功能有两个必填参数。是索引参数。它用于指向数组的第i个位置。第二个参数是array_name。这是第ith个元素的实际数组。此函数返回第ith个元素。
让我们看一个例子来了解这个想法。
示例
#include<iostream>
#include<array>
using namespace std;
main() {
array<int, 10> arr = {00, 11, 22, 33, 44, 55, 66, 77, 88, 99};
cout << "1st element: " << get<0>(arr) << endl;
cout << "6th element: " << get<5>(arr) << endl;
cout << "8th element: " << get<7>(arr) << endl;
cout << "10th element: " << get<9>(arr) << endl;
}输出结果
1st element: 0 6th element: 55 8th element: 77 10th element: 99
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短