← Back to Templates
Question 162
Pair Swap Method
Pair Swap Method
Create a template classPair<T>that holds two values of the same type. The constructor takes two arguments:Pair(T a, T b)Implement: -swap(): swaps the two stored values -print(): prints the two values separated by,followed by a newline Do NOT write a main function.
Expected Output:
1, 2 2, 1
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Templates
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.