Flip a Two-Type Pair
Flip a Two-Type Pair
Complete the class template Pair<T, U>, which stores a first of type T and a second of type U:
- Pair(T a, U b): stores the two values
- void print() const: prints first, then / (space, slash, space), then second, then a newline
- Pair<U, T> flipped() const: returns a NEW pair whose first value is this pair's second and whose second value is this pair's first
Notice the return type: swapping the values also swaps the type arguments, so flipping a Pair<int, std::string> gives a Pair<std::string, int>, a different class made from the same template. The tests print a Pair<int, std::string> holding 1 and one, print its flipped copy, and print the flipped copy of a Pair<char, double> holding x and 2.5, one line each.
Do NOT write a main function.
Expected Output:
1 / one one / 1 2.5 / x
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...