Templated mySwap( ) Function
Explore how to write a generic templated mySwap function that swaps values of different data types including int, float, double, and string. Understand why naming conflicts with STL's swap should be avoided and how templates enable flexible code reuse.
We'll cover the following...
We'll cover the following...
Problem
Write a template function, myswap( ), that interchanges the contents of two variables. Use it to swap integers, floats, long integers, and strings.
Can this function be given a name swap( ) instead of myswap( )?
Sample run
Suppose x ...