From 24b90ff7d6babe5b4598e9b1f0df0701ac517eaf Mon Sep 17 00:00:00 2001 From: Karan Sheth Date: Tue, 9 Oct 2018 22:52:02 +0530 Subject: [PATCH] Error in code - solved Was originally giving error due to function overloading of swap in iostream --- cpp/templates.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/templates.md b/cpp/templates.md index dce6cbc..d36fb86 100644 --- a/cpp/templates.md +++ b/cpp/templates.md @@ -20,7 +20,7 @@ Assume we have to swap two variables of int type and two of float type. Then, we using namespace std ; // creating a generic function ‘swap (parameter-list)’ using template : template -void swap( X &a, X &b) { +void swaping( X &a, X &b) { X tp; tp = a; a = b; @@ -31,8 +31,8 @@ void swap( X &a, X &b) { int main( ) { int a = 10, b = 20 ; float c = 10.5, d = 20.5 ; - swap(a , b); // function swapping ‘int’ elements - swap(c , d); // function swapping ‘float’ elements + swaping(a , b); // function swapping ‘int’ elements + swaping(c , d); // function swapping ‘float’ elements return 0; } ```