Question about Templates and passing arguments
I am currently taking a Data Structures course and we are discussing the topic of templates and its remifications in the world of generic programming. I had a few questions if anyone would like to answer them.
I present to you the swap function as a generic algorithm:
My question is regarding the arguments for this template function. Why are they being passed in like this? Any advantages or disadvantages to this way of argument passing? Thank you.
template <typename T>
void swap (T& t1, &T t2)
temp = t1;
t1 = t2;
t2 = temp;