[log in to unmask] wrote:
>>>>>The only thing Java added
>>>>to C++ was a little bit of (not nearly enough) error-resistance.
>>>
>>>>interfaces
>>>
>>>So what is the difference between a Java Interface and a C++ pure virtual
>>class (apart from the C++ version being less restrictive)?
>
>>Well, consider the following declaration:
>>
>> public class GentleThread implements Runnable {
>> ...
>> }
>>
>>How do you say that in C++ ? I.e., what in C++ corresponds to "implements" ?
>
>In C++, implements would simply be denoted by subclassing Runnable so you'd have:
>
>class GentleThread : public Runnable {
> ...
> }
No, you wrote an essentially different thing. Consider:
public class GentleThread implements Runnable {
...
}
public class BruteThread implements Runnable {
...
}
The way in which the GentleThread implements Runnable may be entirely different
from the BruteThread's implementation of the same interface. Those implementations
of the same interface do not depend from each other. At the same time, your
"C++ versions":
class GentleThread : public Runnable {
...
}
class BruteThread : public Runnable {
...
}
will inherit an identical implementation of the interface Runnable from the
ancestor class. Do you see the difference?
>Interfaces (and 'implements') are essentially Java's way of avoiding the
>problems associated with multiple inheritance.
Certainly, the interface are used in Java for that purpose also, but this
isn't all their value.
Stephen Schwarm <[log in to unmask]> wrote:
>Java does not support multiple inheritance so the is how it specifies
>common interface specifications.
>
>To answer your question directly:
>
>class GentleThread: public class Runnable
>
>Where Runnable has only abstract interfaces.
The same reply for the same arguments.
Alexander Kopilovitch [log in to unmask]
Saint-Petersburg
Russia