Next Spaceship

Driving into future...

How to Use "Pair" in STL?

| Comments

In Python, we have tuple, and in Java, we have Map, but in C++, the language itself doesn’t contain anything equivalent. Nevertheless, we can use STL - the Standard Template Library - to construct the data structure.

Of course, we can construct this by ourself, and it’s not complex, but as we will see, with “pair” we can make it easier and simpler.

This is an example:

``` cpp How To Use Pair In C++ #include

pair<int,int> p; p.first=1; p.second=2; p=make_pair(3,4); ```