#include <iostream> using namespace std; template<class T> class Afficher { public: void operator()(const T& t) { cout << t << " "; } }; int main() { Afficher<int> objAfficher; /* Affichage des entiers */ for (int i = 0; i < 5; ++i) objAfficher(i); cout<<"n"; Afficher<double> objAfficher2; /* Affichage des Doubles */ for (double x = 0; x < 5; ++x) objAfficher2(x); cout<<"n"; Afficher<char> objAfficher3; /* Affichage des caractères */ for (double j = 0; j < 5; ++j) objAfficher3(j+'a'); return 0; } |
----------------------------------------------------------------------------