yeah, you'd load all the players in the group or raid into a container, and go off that. I myself like using a List (called via std::list) Then later when you do the spell, use a random number to pick one out and target them.
One I used to do based on distance from the creature is:
std::list<Unit*> targets;
SelectTargetList(targets, 5, SELECT_TARGET_RANDOM, 25.0f, true);
for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
DoCast(*i, SPELL);
break;