Here is a general implementation. It uses a templatized class,
therefore it will get the combinations of any type of variable,
not just characters. The program takes advantage of the
next_permutation algorithm and uses a set of bits to determine
what to output. The way it works is that you call the
NextCombination() function until there are no more combinations
left. I attached the full code, but I'll go over the main()
function briefly: All this does is initialize my vectors that
will be used. The "elements" vector is a vector of all of the
items I want to take the combination of. The "results" will hold
the results of each time I get a combination. Note that the
template allows combinations of char type. If I wanted to get
the combination of integers, I change the type to <int> (this is
done by template magic). int nItems = 2;
CombinationGenerator<char> CG(elements, nItems); This declares
an instance of a CombinationGenerator class that will generate
combinations. The first argument is the vector of all the