Junk Mailer
Posts: 1
Nickname: junkmailer
Registered: Mar, 2002
|
|
Re: abstract classes
|
Posted: Mar 25, 2002 1:47 PM
|
|
I can think of a few of the top of my head...
1/ In C++, for a class to be abstract, at least one method needs to to a pure virtual method. So what that means is the class can potentially contain other methods that are not pure virtual methods.
In case of interfaces in Java, all methods are abstract.
2/ In C++, the abstract class can contain default implementation of the some of the methods.
In Java, the interface class can not contain any implementation.
3/ In C++, the abstract class can contain, attributes. In Java, the interface class can not contain any attributes.
4/ In C++, when a class inherits from an abstract base class, the child class NEED not implement all of the pure virtual methods defined in the base class. Of ocurse, if all of the pure virtual methods are not implemented some where in the hierarchy then the class will continue to be abstract and cannot be instantiated.
In Java, when an interface is implemented by a class, ALL of the methods in the interface need to be implemented by the class.
These were just some of the differences I could think of. In retrospect abstract class in C++ are more similar to abstract classes, than interfaces, in Java.
Hope that helped.
|
|