#include #include using namespace std; const int MAX = 10; template struct stack { T t[MAX]; int n; }; stack t1; stack< pair > t2; // Le type pair existe directement en C++ ... template bool isEmpty(const stack& s) { return s.n == 0; } template bool isFull(const stack& s) { return s.n == MAX; } template const T& top(const stack& s) { assert(!isEmpty(s)); return s.t[s.n - 1]; } template void push(stack& s, const T& t) { assert(!isFull(s)); s.t[s.n++] = t; } template T pop(stack& s) { assert(!isEmpty(s)); return s.t[--s.n]; } int main(void) { pair p; stack< pair > s; s.n = 0; for(int i = 0; i < MAX; i++) { p.first = i; p.second = 'r' + i; push(s,p); } while(!isEmpty(s)) cout << pop(s).second << endl; return 0; }