adspace
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