Click to See Complete Forum and Search --> : Problem with visitor pattern and interfaces


mscblazer
January 25th, 2009, 08:30 PM
Hello everyone, I've been reading in internet about visitor pattern and some examples, some of them using interface.

And others using abstract class. When I'm using abstract class the application runs perfect but when I prove with interface, there is a problem.

Can anybody help me with this problem ?

Thanks.

darwen
January 25th, 2009, 08:33 PM
I really wish I could mind-read.....

What's the problem exactly ? You need to give more information for us to help you.

Darwen.

mscblazer
January 25th, 2009, 10:15 PM
http://upload.wikimedia.org/wikipedia/commons/b/b1/Visitor_UML_class_diagram.svg

Look this diagram carefully, Visitor & Element are Interfaces(no abstract classes), when I tried to program according to diagram, only one visitant(operation) executes an element.

When I tried with another operation with the same or another element, this execution is ignore.

Only with inheritance it works, not using interfaces.