Associative arrays in C++ Last Updated : 09 Feb, 2022 Comments Improve Suggest changes Like Article Like Report Associative arrays are also called map or dictionaries. In C++. These are special kind of arrays, where indexing can be numeric or any other data type i.e can be numeric 0, 1, 2, 3.. OR character a, b, c, d... OR string geek, computers... These indexes are referred as keys and data stored at that position is called value. So in associative array we have (key, value) pair. We use STL maps to implement the concept of associative arrays in C++. Example: Now we have to print the marks of computer geeks whose names and marks are as follows Name Marks Jessie 100 Suraj 91 Praveen 99 Bisa 78 Rithvik 84 CPP // CPP program to demonstrate associative arrays #include <bits/stdc++.h> using namespace std; int main() { // the first data type i.e string represents // the type of key we want the second data type // i.e int represents the type of values we // want to store at that location map<string, int> marks{ { "Rithvik", 78 }, { "Suraj", 91 }, { "Jessie", 100 }, { "Praveen", 99 }, { "Bisa", 84 } }; map<string, int>::iterator i; cout << "The marks of all students are" << endl; for (i = marks.begin(); i != marks.end(); i++) cout << i->second << " "; cout << endl; // the marks of the students based on there names. cout << "the marks of Computer geek Jessie are" << " " << marks["Jessie"] << endl; cout << "the marks of geeksforgeeks contributor" " Praveen are " << marks["Praveen"] << endl; } Output: The marks of all students are 84 100 99 78 91 the marks of Computer geek Jessie are 100 the marks of geeksforgeeks Praveen are 99 Comment More infoAdvertise with us Next Article Associative arrays in C++ S SrjSunny Follow Improve Article Tags : Technical Scripter Competitive Programming C++ DSA STL cpp-map +2 More Practice Tags : CPPSTL Similar Reads array::at() in C++ STL Array classes are generally more efficient, light-weight and reliable than C-style arrays. The introduction of array class from C++11 has offered a better alternative for C-style arrays. array::at() This function is used to return the reference to the element present at the position given as the par 2 min read Array class in C++ The introduction of array class from C++11 has offered a better alternative for C-style arrays. The advantages of array class over C-style array are :- Array classes knows its own size, whereas C-style arrays lack this property. So when passing to functions, we don't need to pass size of Array as a 6 min read Arrays for Competitive Programming In this article, we will be discussing Arrays which is one of the most commonly used data structure. It also plays a major part in Competitive Programming. Moreover, we will see built-in methods used to write short codes for array operations that can save some crucial time during contests. Table of 15+ min read Practice questions on Arrays In this article, we will discuss some important concepts related to arrays and problems based on that. Before understanding this, you should have basic idea about Arrays.Type 1. Based on array declaration - These are few key points on array declaration: A single dimensional array can be declared as 6 min read C++ Omit Array Size Prerequisite: Array in C++ The array is a type of data structure that can store data of similar data types. The most significant feature is fixed size. There are two conditions by which we can check the initialization of the array. Methods for Declaring Array 1. Declaring size during initialization: 2 min read Array of Strings in C++ In C++, a string is sequence of characters that is used to store textual information. Internally, it is implemented as a dynamic array of characters. Array of strings is the array in which each element is a string.We can easily create an array of string in C++ as shown in the below example:C++#inclu 4 min read STD::array in C++ The array is a collection of homogeneous objects and this array container is defined for constant size arrays or (static size). This container wraps around fixed-size arrays and the information of its size are not lost when declared to a pointer. In order to utilize arrays, we need to include the ar 5 min read Jagged Arrays in C++ Prerequisite: Arrays in C++ An array of pointers in C++Dynamic 2D arrays in C++What is a Jagged Array? A jagged array is an array of arrays such that member arrays can be of different sizes, in 2D array terms for each row we can have a variable number of columns. These types of arrays are also known 4 min read Types of Arrays There are majorly 4 types of arrays1. Fixed Size Array2. Dynamic Sized Array3. 1-Dimensional Array4. Multi-Dimensional ArrayClassification of Types of ArraysHowever, these array types can be broadly classified in two ways:On the basis of SizeOn the basis of DimensionsTypes of ArraysTable of ContentC 4 min read C++ Arrays In C++, an array is a derived data type that is used to store multiple values of similar data types in a contiguous memory location.Arrays in C++Create an ArrayIn C++, we can create/declare an array by simply specifying the data type first and then the name of the array with its size inside [] squar 10 min read Like