What is vector pair in c++?



What is vector pair in c++?..

Answer / 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

More C++ General Interview Questions

what is pulse code modulation?

2 Answers   Wipro,


What is the use of dot in c++?

1 Answers  


What is encapsulation in c++?

2 Answers  


What is recursion?

7 Answers  


What return value must conversion operators have in their declaration?

1 Answers  


How do I run a program in notepad ++?

1 Answers  


What is static class data?

1 Answers  


Write a corrected statement in c++ so that the statement will work properly. x + y=z;

2 Answers  


Is c better than c++?

1 Answers  


Difference between strdup and strcpy?

1 Answers  


What is meant by forward referencing and when should it be used?

1 Answers  


Describe the syntax of single inheritance in C++?

1 Answers   Fidelity,


Categories