this function is capable of converting integers to any base format 2-16. this includes binary, octal, and hexadecimal. adding larger bases is as simple as lengthening the alpha string.
//this recursive base converter is valid for base 2~16
void Converter::toBase(int n, int base)
{
string alpha="0123456789ABCDEF";
if (n > 0)
{
toBase(n/base,base);
cout << alpha[n%base];
}
}