pair type in C++
Level 3153 keystrokes
A pair holds two values, possibly of different types, accessed as first and second. Prints Alice and 25, then changes second to 26 and prints it.
C++ code
// The template arguments give the types of the two values: string and int1pair<string, int> person = {"Alice", 25};// first is the first value: Alice2cout << person.first << endl;// second is the second value: 253cout << person.second << endl;// The members can be assigned directly4person.second = 26;// Prints the new value 265cout << person.second << endl;Output
Alice 25 26
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 13;× 5.× 4,× 2"× 2=× 2{× 1}× 1>× 1