Hello all,
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:
Code:
template <typename T>
void swap (T& t1, &T t2)
{
T temp;
temp = t1;
t1 = t2;
t2 = temp;
}
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.