TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date: Tue, 6 Feb 2001 17:46:05 +0000
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
In-Reply-To: <[log in to unmask]>
Parts/Attachments: TEXT/PLAIN (42 lines)
>>>>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 {
   ...
   }

Interfaces (and 'implements') are essentially Java's way of avoiding the
problems associated with multiple inheritance. The subtlety is that in Java you
can implement as many interfaces as you like, but you can only extend a single
class. In C++ you can extend multiple classes (and take the blame when the whole
thing blows up in your face :-)

John



********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender
immediately by telephoning +44(1252) 373232. You should not copy it
or use it for any purpose nor disclose or distribute its contents to
any other person.
********************************************************************

ATOM RSS1 RSS2