adspace


What is vector pair in c++?

Answer Posted / Chayan Singh

In C++, a std::pair is a container that holds two elements of different or the same types. A vector of pairs, denoted as std::vector<std::pair>, stores a sequence of pairs. Here's an example:n```cppn#include <iostream>n#include <vector>n#include <utility>nnint main() {n std::vector<std::pair<int, std::string>> vec;n vec.push_back(std::make_pair(1, "One"));n vec.push_back(std::make_pair(2, "Two"));n for (const auto &pair : vec) {n std::cout << pair.first << ": " << pair.second << 'n';n }n return 0;n}n```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the latest version on c++?

1209


daily Routine of father

1485


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1165


Can union be self referenced?

1267


What character terminates all character array strings a) b) . c) END

1397