Thanks, that helped a lot.
I have edited my code and it now compiles, however I am stuck in an infinite loop (the "Processing\n" part repeats forever)
Code:
#include <string>
#include <iostream>
#include <set>
#include <list>
using namespace std;
void string_permutation(list<int>& orig, list<int>& perm )
{
if(orig.empty())
{
list<int>::iterator theIterator;
for(theIterator = orig.begin(); theIterator != orig.end(); theIterator++)
{
cout << *theIterator << " - ";
}
return;
}
list<int>::iterator theIterator;
for(theIterator = orig.begin(); theIterator != orig.end(); theIterator++)
{
cout << "Processing\n";
list<int> orig2 = orig;
orig2.erase(theIterator);
list<int> perm2 = perm;
perm2.push_back(*theIterator);
string_permutation(orig2,perm2);
}
}
int main()
{
int myInts[] = {1, 2, 3, 4};
list<int> orig(myInts, myInts+4);
list<int> perm;
string_permutation(orig,perm);
system("Pause");
return 0;
}