Hi I have a class where I define a

Code:

vector<char *> myVector

to be a private variable.

This variable will store permutations of a string

For example, if the string is "123" it will store "123","213","321" etc

I then define a function that does the permutations, the function is the following:

Code:

void PermClass::findPerms(char *set, int begin, int end){
int i;
int range = end - begin;
if(range == 0) myVector.push_back(set);//(1)
else{
for(i=0;i<range;i++){
swap(set[begin],set[begin+i]);
findPerms(set,begin+1,end);
swap(set[begin],set[begin+i]);
}
}
}

I have tried some debugging and realized that the variable "set" has the next permutation at position (1).

However, when the recursion ends, when I output the values of the vector by using an iterator like this:

Code:

void PermClass::showVector(){
int i;
vector<char *>::iterator it;
for(it = myVector.begin(); it!=myVector.end(); it++){
cout<<*it<<endl;
}
cin.get();
}

I get as an output

Code:

123
123
123
123
123
123

can someone explain me what's wrong? thanks in advance