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

Sacred Thought

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...