© 2012 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies
« NS2  Projects »

Home Lab Exercise Object Oriented Programming Lab Exercise Programs CPP Program To Overriding Template Function▼


CPP Program To Overriding Template Function

Alogarithm steps:

Step 1: Declare the template function

Step 2: Declare the overload function swap args.

Step 3: Call the overloaded function swap args with float arguments.

Step 4: Call the overload function swap args with char arguments.

Step 5: Display the content.

CPP Program To Overriding Template Function

#include template void swapargs(X &a,X &b) { X temp; temp = a; a=b; b=temp; cout<<"Inside the template swapargs"; } void swapargs(int &a,int &b) { int temp; temp=a; a=b; b=temp; cout<<"Inside swapargs int specialization"; } int main() { int i=0,j=20; double x=10.1,y=23.3; char a='x',b='z'; cout<<"original i,j : "<

SAMPLE INPUT AND OUTPUT:

 Original i, j : 10  20

 original x, y : 10.1  23.3

 original a, b : x z

 Inside swapargs int specialization

 Inside the template swapargs

 Inside the template swapargs

 Swapped i, j: 20 10

 Swapped x, y: 23.3 10.1

 Swapped a, b : Z x

 
SLogix Student Projects

⇓ Student Projects ⇓
⇑ Student Projects ⇑
bottom