All of the examples so far do the job, I'll admit. But, what about us non-beer-drinkers? Fortunately, wielding the almighty power of C++, it's not too difficult to make a good version that works with other types of beverages.

Note that this also allows minors to enjoy an infinite thirst-quenching experience without potentially breaking laws that may prohibit that kind of activity if it involved alcohol.

Also, I believe instead of "infinity bottles of" anything, it might be more correct to say an "infinite number of" something. But, hey, keeping with the way everyone else is doing it, I won't be the one to mess up the song. ;)

#include <iostream>
#include <string>

template <typename beverage_traits>
class InfiniteBeverage {
public:
  InfiniteBeverage() {
    const string &name = beverage_traits::name();
    while (1) {
      std::cout << "Infinity bottles of " << name << " on the wall!\n"
                << "Infinity bottles of " << name << ",\n"
                << "Take one down, pass it around.\n"
                << "Infinity bottles of " << name << "!\n\n";
    }
  }
};

class Coke {
public:
  static const string &name() const { return "Coke"; }
};

// provided for backward compatibility
class Beer {
public:
  static const string &name() const { return "beer"; }
}

int main() {
  InfiniteBeverage<Coke> infiniteCoke;
}