Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Visitor
- {
- public void DoSomething(ITree tree)
- {
- // treeを使って何かする
- tree.GoToParent(this);
- }
- }
- public interface ITree
- {
- // なんかプロパティもありつつ
- void GoToParent(Visitor visitor);
- }
- public class Node : ITree
- {
- ITree parent;
- public void GoToParent(Visitor visitor)
- {
- visitor.DoSomeothing(parent);
- }
- }
- public class Root : ITree
- {
- public void GoToParent(Visitor visitor)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement