Can someone help me fix this part of a recursive class
Unsolved
General and Desktop
-
void Node::put_recurse(Node inp, int idx) { if (children.size() > 0 && curChild < children.size()){ if (idx > 0){ children.push_back(inp); }else{ idx--; children.at(curChild).put_recurse(inp, idx); } } }
the children and curChild are a part of the Node class
-
Hi,
And what is the issue ?
-
I get some error message about the type it suggests const, but I add const and it doesn't help
-
@AI_Messiah said in Can someone help me fix this part of a recursive class:
children.at(curChild)
This returns a const ref (or object). Use a function which returns a non-const ref.
-
@AI_Messiah said in Can someone help me fix this part of a recursive class:
I get some error message about the type it suggests const, but I add const and it doesn't help
When asking for help, you are supposed to copy & paste the error message, which probably shows a line number, and show whatever you tried to resolve. Rather than leaving people to just guess.