#include <iostream>
template<class T>
class Example {
public:
T a, b;
Example(T x, T y) : a(x), b(y) {} // constructor
void swap();
};
template<class T>
void Example<T>::swap() {
T tmp = a;
a = b;
b = tmp;
}
int main() {
int x = 10;
int y = 25;
Example<int> obj(x, y);
std::cout << obj.a << " " << obj.b << "\n";
obj.swap();
std::cout << obj.a << " " << obj.b;
}
/*
run:
10 25
25 10
*/