Horje
c++ list of pairs Code Example
c++ list of pairs
#include <iostream>
#include <list>
using namespace std;

int main() {
	list<pair<int, char>> pair_list;
  	
  	pair_list.push_front(make_pair(1, 'a'));
    pair_list.push_front(make_pair(2, 'b'));

    pair_list.push_back(make_pair(10, 'x'));
    pair_list.push_back(make_pair(20, 'y'));
  
  	for(auto itr=pair_list.begin();itr!=pair_list.end();itr++) {
    	cout << itr->first << ", " << itr->second << endl;
    }
  
  	return 0;
}

// output
/* 
	2, b
	1, a
	10, x
	20, y
*/




Cpp

Related
Hash Sort in C++ Code Example Hash Sort in C++ Code Example
c++ enum Code Example c++ enum Code Example
parking charge system project c++ Code Example parking charge system project c++ Code Example
c++ code Code Example c++ code Code Example
C++ Join thread Code Example C++ Join thread Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10