The array::get() is a built-in function in C++ STL which returns a reference to the i-th element of the array container.
Parameters: The function accepts two mandatory parameters which are described below.
- i – position of an element in the array, with 0 as the position of the first element.
- arr_name – an array container.
Return Value: The function returns a reference to the element at the specified position in the array
Time complexity: O(1)
Below programs illustrate the above function:
arr = 10 arr = 20 arr = 30
arr = a arr = b arr = c
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- array at() function in C++ STL
- Sum 2D array in Python using map() function
- getline() function and character array
- How to return a local array from a C/C++ function?
- Declare a C/C++ function returning pointer to array of integer pointers
- Difference between user defined function and library function in C/C++
- array::fill() and array::swap() in C++ STL
- array::cbegin() and array::cend() in C++ STL
- Array with GCD of any of its subset belongs to the given array
- array::front() and array::back() in C++ STL
- Sorting an array according to another array using pair in STL
- array::rbegin() and array::rend() in C++ STL
- array::crbegin() and array::crend() in C++ STL
- Array of Structures vs. Array within a Structure in C/C++
- What’s difference between “array” and “&array” for “int array” ?
- Check if Array elements can be maximized upto M by adding all elements from another array
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- array::begin() and array::end() in C++ STL
- How to call function within function in C or C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.