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
- 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
- Function Overloading vs Function Overriding in C++
- Array with GCD of any of its subset belongs to the given array
- array::fill() and array::swap() in C++ STL
- Sorting an array according to another array using pair in STL
- array::front() and array::back() in C++ STL
- array::rbegin() and array::rend() in C++ STL
- array::cbegin() and array::cend() in C++ STL
- array::crbegin() and array::crend() in C++ STL
- What’s difference between “array” and “&array” for “int array” ?
- What happens when a virtual function is called inside a non-virtual function in 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.