F
Frederick Dean
Hi,guys!
I'm reading Stephen Dewhurst's book "C++ Gotchas"£¬in gothca #7, I
meet a weird case:
bool Postorder::next() {
switch (pc)
case START:
while (true)
if (!child()) {
pc = LEAF;
return true;
case LEAF:
while (true)
if (sibling())
break;
else if (parent()) {
pc = INNER;
return true;
case INNER: ;
} else {
pc = DONE;
case DONE: return false;
}
}
}
I can't understand how the case goes, those cases are not even in the
same level, the author does not explain how the cases execute, could you
please help me with this? Any help is appreciated, thanks!
I'm reading Stephen Dewhurst's book "C++ Gotchas"£¬in gothca #7, I
meet a weird case:
bool Postorder::next() {
switch (pc)
case START:
while (true)
if (!child()) {
pc = LEAF;
return true;
case LEAF:
while (true)
if (sibling())
break;
else if (parent()) {
pc = INNER;
return true;
case INNER: ;
} else {
pc = DONE;
case DONE: return false;
}
}
}
I can't understand how the case goes, those cases are not even in the
same level, the author does not explain how the cases execute, could you
please help me with this? Any help is appreciated, thanks!