Last Updated : 10 Apr, 2024

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

  1. pair p1;
  2. pair p2;
  3. pair p3;
  4. pair 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