The problem is with your expressions of this form:
(new string *)(c1)
The left hand side isn't a type, it's an expression. When you suffix it with another parenthesized expression it looks like a function call but that only works if the left expression is a function name or function pointer. In this case the new expression has type std::string**
which isn't a function pointer.
To construct a temporary string from a single char
, you shouldn't use new
which dynamically allocates an object; instead you can use a constructor. A suitable one is the one which takes a count and a char
to repeat for that count. In your case a count of 1 is what you want:
std::string(1, c1);
You can do something like.
return std::string(1, c1) + std::string(1, c2);
Note that you also don't call generate anywhere and if you do return
from the first iteration of a for
loop you aren't going to be iterating through all the combinations, you will only every generate the first compination.