Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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
*/
Comment

PREVIOUS NEXT
Code Example
Cpp :: vectors in c++ 
Cpp :: c++98 check if character is integer 
Cpp :: c++ online compiler 
Cpp :: c++ linked list delete node 
Cpp :: move assignment operator c++ 
Cpp :: assignment operator with pointers c++ 
Cpp :: c++ convert to assembly language 
Cpp :: casting to a double in c++ 
Cpp :: c++ awitch statements 
Cpp :: c++ write string 
Cpp :: delete c++ 
Cpp :: minimum characters to make string palindrome 
Cpp :: transpose matrix c++ vectors 
Cpp :: c++ pass function as argument 
Cpp :: heap allocated array in c ++ 
Cpp :: pointer to pointer c++ 
Cpp :: C++ Class Template Declaration 
Cpp :: ? c++ 
Cpp :: visual studio code terminal keeps closing c++ 
Cpp :: array bubble sort c++ static 
Cpp :: c++ throw index out of bound 
Cpp :: how to scan vector in c++ 
Cpp :: c++ to c converter tool 
Cpp :: strcmp in c++ header file 
Cpp :: c++ bind port 
Cpp :: c to assembly mips converter 
Cpp :: grepper users assemble 
Cpp :: find with hash set 
Cpp :: Qt asynchronous HTTP request 
Cpp :: Your age doubled is: xx where x is the users age doubled. (print answer with no decimal places) 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =