#include<iostream.h>
#include<conio.h>
template <class T>
T swap(T &a, T &b)
{
T temp;
temp = a;
a = b;
b = temp;
return b;
}
int main()
{
clrscr();
int x, y;
float p, q;
double dv1, dv2;
cout<<endl;
cout<<"Enter two integers" <<endl;
cin >>x>>y;
cout<<endl;
cout<<"Before swapping, x = "<<x<<" and y = "<<y<<endl;
swap (x,y);
cout<<"After swapping, x = " <<x<< " and y = "<<y<<endl;
cout<<endl;
cout<<"Enter two floating-point numbers "<<endl;
cout<<endl;
cin>>p>>q;
cout<<"Before swapping, p = "<<p<<"and q = "<<q<<endl;
swap(p,q);
cout<<endl;
cout<<"After swapping, p = " <<p<< " and q = "<<q<<endl;
cout<<"Enter two double-precision numbers"<<endl;
cin>>dv1>>dv2;
cout<<endl;
cout<<"Before swapping, dv1 = "<<dv1<<" and dv2 ="<<dv2<<endl;
swap (dv1, dv2);
cout<<"After swapping, dv1 = "<<dv1<<" and dv2 = "<<dv2<<endl;
getch();
return 0;
}
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement 
Corporate Services
  Web Design and development
  Web Promotion (SEO)
  Multimedia/CD Presentation
  Software development

  E.Commerce

Training@balujalabs

  Software Courses
  Hardware Courses
  Networking.Courses
  Mobile Repairing Courses
  UGC Degrees
Student Corner
 Programming & Projects
 Placement Papers
 Project Ideas
 Synopsis Ideas

  Franchise Section

 Administrator
Franchise Inquiry
 
 

This program is to define a function template to swap the contents of two data items of type int, float, and double.

 

 

 

 

 

 

 

 

 

                                                                                                                                          

1 This program creates a function template to find the square of a no. of type int and float.
2 This program is to define a function template to swap the contents of two data items of type int, float, and double.
3 This program illustrates the function templates instantiation.
4 This program illustrates the function template instantiation where the template parameter list contains both template type and template non-type parameters.
5 This program illustrates the template arguments with L value transformation.
6 This program illustrates the inclusion compilation model of the function template.
7 This program illustrates the function template explicit specialization.
8 This program illustrates the overloaded function templates.
9 This program illustrates the overloaded resolution of templates instantiation and an ordinary function call.

 

     
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement