c++ std::pair code example
Example 1: pair c++
#include <utility>
#include <iostream>
int main () {
std::pair <int,int> foo;
std::pair <int,int> bar;
foo = std::make_pair (10,20);
bar = std::make_pair (10.5,'A');
std::cout << "foo: " << foo.first << ", " << foo.second << '\n';
std::cout << "bar: " << bar.first << ", " << bar.second << '\n';
return 0;
}
Example 2: c++ std::pair
#include <utility>
#include <string>
#include <iostream>
int main () {
std::pair <std::string,double> product1;
std::pair <std::string,double> product2 ("tomatoes",2.30);
std::pair <std::string,double> product3 (product2);
product1 = std::make_pair(std::string("lightbulbs"),0.99);
return 0;
}