I have problems with a class method returning all paths of binary tree. My compiler (Visual Studio) doesn't allow recursion in this instance; Additionally I get error C2440, apparently for trying to convert <lambda_276bde719f5b574aaaebc799da75f887>" to "int" (?)
string* tree::binaryCoding(string list) {
string* binaryList = new string[list.length()];
node *temporaryNode=trunk;
auto h = [=](node* current, string position) -> void{
if (current->getCharacter() != NULL) {
int i = 0;
while (binaryList[i] != "") ++i;
binaryList[i] = current->getCharacter() + position;
return;
};
h(current->getOne(), position + "1");
h(current->getZero(), position + "0");
};
h(trunk, "");
return binaryList;
}
I've tried making two lambdas identical in functionality that called each other, but the first one couldn't use the second one. I want to know if what I'm doing is valid or if I should take a different approach.