// 99 bottles of beer, C++ template 'meta-programming' version // By Arion Lei (philipl@cs.ust.hk) #include template class Loop { public: static inline void f () { cout << I << " bottles of beer on the wall," << endl << I << " bottles of beer." << endl << "Take one down, pass it around," << endl << I-1 << " bottles of beer on the wall." << endl; Loop::f(); } }; class Loop<0> { public: static inline void f () { cout << "Go to the store and buy some more," << endl << "99 bottles of beer on the wall." << endl; } }; int main () { Loop<3>::f(); return 0; }