#include #include using namespace std; //T must be puttable (printable with <<) in the following templates. template inline void print(const T& t) {cout << t;} //accepts any type template void print(const T *p) //accepts pointer to any non-void type { cout << p; if (p != 0) { cout << " -> " << *p; } } template void print(const T *const *pp) //accepts pointer to pointer to any non-void type { cout << pp; if (pp != 0) { cout << " -> " << *pp; if (*pp != 0) { cout << " -> " << **pp; } } } int main() { int i = 10; print(i); cout << "\n"; const int *p = &i; print(p); cout << "\n"; const int *const *pp = &p; print(pp); cout << "\n"; const int *const *const *ppp = &pp; print(ppp); cout << "\n"; return EXIT_SUCCESS; }