Last Updated : 10 Apr, 2024

Given below are some ways to declare and initialize pair. Choose the correct alternative way to do so:

  
a) pair <int, char> p1
b) pair <char, int> p2
c) pair <int, int> p3
d) pair <char, char> p4

(A) a) and b)
(B) c) and d)
(C) a) and d)
(D) All of them


Answer: (D)

Explanation:
Pair is used to combine together two values which may be different in type. Pair provides a way to store two heterogeneous objects as a single unit.


Share your thoughts in the comments