Java says ‘extends’, c++ uses a colon.
class Java extends Baseclass {} |
class Cplusplus : Baseclass {}; |
Java says each class can have at most one base class
C++ says each class can have any number of base classes. If those base classes have items of the same name, then you better be clear which one you mean when you use this shared name.
Java has interfaces. This helps them overcome the limitations of not having multiple inheritance.
C++ doesn’t. It uses multiple base classes and “abstract base classes” instead.
In Java, you say super.
In C++, you use a colon.
public foo(int
arg) super(foo); |
foo(int
arg) : base(arg) // Other stuff |
In Java, every function is virtual. You have no other choice.
In C++, things are only virtual if you say so. Remember, constructors cannot be virtual by c++ law.
In both languages, the base class’s constructor is called, then the derived class.
In Java, there is no such thing.
In c++, they exist. They are called for the derived class, then the base class. This is the opposite order of the constructors.