![]() |
Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Interfaces are similar to Mixin's in C++. Mixin is a class that does not implement any method but are in fact has only pure virtual methods. The implementor decides the logic for these methods. Also, The article mentions advantage of interface over single inheritence but The Animal class could always be mixed in with a Talkative class in which case the result would have been the same as interace. e.g. In C++ (or Java)... class Talkative { class Animal : public Talkative { class Dog : public Animal { class CuckooClock : public Talkative { class Interrogator { Also, I don't understand how interfaces are any better than doing multiple inheritance since interfaces could cause code repeatability. e.g. In Java... public class Context { public class Board { public abstract class ColorBoard extends Board { public class WhiteBoard extends ColorBoard { public class PrintableBoard extends Board ( What if I now want to write a class for PrintableWhiteBoard ? public class PrintableWhiteBoard extends WhiteBoard implements Printable { I agree thar an inheritence involving a diamond is complicated but it works fine if you have a good insight into the language. I'm a huge java fan but I guess that both languages have their up sides and down sides. Thanks,
Replies: |
Sponsored Links
|