I saw some smart guys using permutation to solve this problem. So, I revised my solution like below.

void getPermutation(vector<string>& result, string s, int level) {
if (level == s.length()) {
result.push_back(s);
return;
}
for (int i = level; i<s.length(); i++) {
if (level < i && s[level] == s[i])
continue;
swap(s[level], s[i]);
getPermutation(result, s, level + 1);
}
}
vector<string> generatePalindromes(string s) {
vector<string> result;
string candidates;
char oddChar = 0;
int chars[256] = { 0 };
for (int i = 0; i<s.length(); i++)
chars[s[i]]++;
for (int i = 0; i<256; i++) {
if (chars[i] % 2 == 1) {
if (oddChar > 0) return result;
oddChar = i;
}
for (int j = 0; j<chars[i] / 2; j++)
candidates.push_back(i);
}
sort(candidates.begin(), candidates.end());
getPermutation(result, candidates, 0);
if (oddChar > 0) {
for (int i = 0; i < result.size(); i++) {
string t = result[i];
reverse(t.begin(), t.end());
result[i] += string(1, oddChar) + t;
}
}
else {
for (int i = 0; i < result.size(); i++) {
string t = result[i];
reverse(t.begin(), t.end());
result[i] += t;
}
}
return result;
}