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

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows