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

26 April 2024  Dear friends, I write the explanation of two verses of Geets for all of you, I hope you all will like it and benefit from it....