Get the App
SLTechnology News&Howtos  ›  Development  › 

Introduction to the example usage of pair method and vector method in C++

Shulou Source: shulou.com Published: 2022-06-03 17:51:48 09月28日 Update

This article mainly explains "Introduction to the example usage of pair method and vector method in C++". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "Introduction to the example usage of pair method and vector method in C++" together.

The pair method.

Template struct pair

Parameters: T1 is the data type of the first value and T2 is the data type of the second value.

Function: pair combines a pair of values into a single value, which can have different data types (T1 and T2) and can be accessed by pair's two public functions, first and second.

Specific usage:

Access to two elements (via first and second):

pair p1; //Use default constructor p1.first = 1;p1.second = 2.5;cout

Tags: Elements vectors functions methods points types iterations data instances examples two number location array learning maximum same content dynamic size Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno vpn macOS Shulou Information