TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
Reply To:
Date:
Tue, 6 Feb 2001 17:46:05 +0000
Content-Type:
TEXT/PLAIN
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