← Back to Question List
C++ Quiz #116
Pair<int, double> Versus Pair<double, int>
Both objects are made from the same class template. Which statement about a and b is true?
📄 Code
1#include <iostream>23template <typename K, typename V>4class Pair {5 K first;6 V second;7public:8 Pair(K f, V s) : first(f), second(s) {}9 void print() const { std::cout << first << " " << second << "\n"; }10};1112int main() {13 Pair<int, double> a(1, 2.5);14 Pair<double, int> b(2.5, 1);15 a.print();16 b.print();17 return 0;18}