Sunday, February 25, 2018

C++ program : Template Class

#include <iostream>
#include <string>
using namespace std;
void Swap(int& a,int& b  ){
int temp;
temp=a;
a=b;
b=temp;

}
void Swap(double& a,double& b  ){
double temp;
temp=a;
a=b;
b=temp;

}
void Swap(string& a,string& b  ){
string temp;
temp=a;
a=b;
b=temp;
}
int main() {
    int a, b;
    double s, t;
    string mr, ms;
    cin >> a >> b;
    cin >> s >> t;
    cin >> mr >> ms;
    Swap(a, b);
    Swap(s, t);
    Swap(mr, ms);
    cout << a << " " << b << " ";
    cout << s << " " << t << " ";
    cout << mr << " " << ms;
    return 0;
}

Thanks
Happy programming !


No comments:

Post a Comment

What is a data structures

  Data structure is a tool in the hands of a programmer for  storing a large number of data items  in the main memory (RAM) of a computer wh...