How to implement an array with string index

Print Friendly, PDF & Email

I had shown you how to implement an array with string based index in Python programming language in the previous post. In this post, I will explain the same problem but the programming language for the implementation is C++. The principle behind of the scene is to use map STL.

Overview of map STL

Map is among of advanced data types characterising as associative containers. It means that each element in such a container is a combination of key and value. This class is one of standard template libraries in C++.

The values can be accepted by arbitrary data types. Hence we can use the string as the indices of a map.

Associative Array
Associative Array



Leave a Reply

Your email address will not be published. Required fields are marked *



This site uses Akismet to reduce spam. Learn how your comment data is processed.