Está en la página 1de 1

C++ Versus Java

FEATURES PRESENT IN C++ AND ABSENT IN JAVA:

Pointers – Referencing and Dereferencing arbitrary memory locations


Reference Variable – To explicitly allow both calls by value and reference without use of pointers
Structures and Unions – Packing aggregate data types into named contiguous memory locations
Global Data – To facilitate modular software development using shared data paradigm
Implicit Typecasting – Automatic casting of data to the best fitting compatible data types
Operator Overloading – Syntactic sugar used to modify operator semantics relative to a class
Destructors – To free dynamic memory and finalize an object at its exact time of destruction
Multiple Inheritance – Multiple base classes for a derived class in an inheritance network
Default Arguments – Default values for function arguments if not explicitly specified in a program

FEATURES PRESENT IN JAVA AND ABSENT IN C++:

Unicode support – Allows international character sets to be encoded in a java character or string
Garbage Collection – Automatic Finalization of objects when the Reference Counter hits zero
Packages – To group like classes into a single namespace called a package
>>> – The unsigned right shift operator in addition to other C++ bitwise operators
Documentation Comments – For automatic documentation generation using “javadoc”
Interfaces – A Class prototype with no implementation, to allow flexible inheritance and callbacks
Labeled Break and Continue – To resolve any ambiguity relating to the target of a break/continue

OTHER DIFFERENCES:

JAVA C++
Java has built-in multithreading support in the OS dependent external libraries like POSIX
form of Thread classes, synchronization Threads, Win32 Threads have to be used to
primitives, mutual exclusion etc. implement multithreaded applications
The Boolean Data type cannot be treated as an C++ internally represents Booleans as follows
integer with 0 or 1 values false = 0, true = any non-zero value
Thrown exceptions must have a handler which Exceptions need not be caught in C++. Such
either handles the exception’s class or one of unhandled exceptions are handled by calling
its base classes the “abort” routine to terminate the program
All exceptions must be classes derived from a Exceptions can belong to any class or can
inheritance network whose root is the even be a basic data type such as int or char or
Throwable class float or pointers like char *
The scope of an access control indicator in a The scope of an access control indicator in a
class is limited to a single variable or function class spans until the next occurrence of such
declaration statement an indicator or until the end of the class
declaration
Object is destructed whenever the Garbage Object is destructed as soon as its scope is
Collection routine is automatically or manually completed or when the delete operator is
invoked. invoked to destroy dynamically created objects

También podría gustarte