EP 241 Computer Programming
 


EP241 - Homework


Exchange Function

Following functions swaps two arguments by using a third local variable, z.
Rewite a generic function without using the third variable.


datatype exchange(datatype &x, datatype &y){
  datatype z = x;
  x = y;
  y = z;
}
where datatype can be any fundamental data type in C++ (double, float, int, etc).
So, your function must work for all data types.
University of Gaziantep - Department of Engineering Physics (2005 - 2024)