Ваші коментарі

固定,谢谢!

Hi Eric!

As far as I know, C is not an OOP language, therefore the patterns aren't applicable there. Probably there are design patterns specific to the C language, but since they are very specialized, I doubt that they'll be covered here.

嗨!

谢谢! 你能发布截图吗? 我无法重现。

Btw, using an iterator along with the visitor is a very common thing.

From what I see, you'll have to depend on some of the concrete classes from the original tree anyway, unless it exposed methods to distinguish between leaf/component classes. So, the question seems to be where that dependency is least awkward to have. If you're building a universal mapper, certainly you should provide some means to inject that dependency to the mapper. But if it's a mapper built for a specific thing, which unlikely to be changed in the near future, I'd always go the easy route and hardcode the required tree classes in it. You can always refactor your way out of it if needed.