#include #include #include "date.h" using namespace std; //Swap the values of a and b. //T must be copy constructable (line 12) and assignable (lines 13-14). template inline void swap(T *a, T *b) { const T temp = *a; *a = *b; *b = temp; } int main() { int i = 10; int j = 20; ::swap(&i, &j); //change T to int cout << "i == " << i << ", j == " << j << "\n"; double d = 3.14; double e = 2.71; ::swap(&d, &e); cout << "d == " << d << ", e == " << e << "\n"; date today; date tomorrow = today + 1; ::swap(&today, &tomorrow); //change T to date cout << "today == " << today << ", tomorrow == " << tomorrow << "\n"; const char *p = "hello"; const char *q = "goodbye"; ::swap(&p, &q); //change T to const char * cout << "p == \"" << p << "\", q == \"" << q << "\"\n"; return EXIT_SUCCESS; }