+ 14

What are C++ features missing in Java?

23rd Apr 2017, 12:02 PM
Osama Ibrahim
Osama Ibrahim - avatar
5 Réponses
+ 7
@Denis, In short, C++ needs the user to free the memory, where java (garbage collector) does it automatically. It is not standard in c++ to perform this automatically. In C and C++, any memory that is allocated on the heap (e.g. using malloc or new) must be explicitly freed by the programmer (e.g. using free or delete). Forgetting to free memory leads to memory leaks, and in long-running programs can lead to the memory usage of the program growing very large. Java provides garbage collection, meaning that memory is freed automatically when it is no longer reachable by any references. This prevents memory leaks, but can lead to pauses in execution while the garbage collector runs. Also, there is no promise of timely destruction in Java. Source: http://www.codemiles.com/java/c-java-memory-management-t473.html
23rd Apr 2017, 3:02 PM
Billy Tsouvalas
+ 6
Multiple inheritance is a very important aspect of c++ missing in java. Also java supports automatic memory management, where c++ does not (garbage/class destructors).
23rd Apr 2017, 12:22 PM
Billy Tsouvalas
+ 2
Billy, smart pointers are standard in c++11 and c++14. The problem is that not all compilers include those standards by default. It will probably be default in a few versions of gcc, for example.
23rd Apr 2017, 7:17 PM
Denis Felipe
Denis Felipe - avatar
+ 1
Speed.
23rd Apr 2017, 2:34 PM
Denis Felipe
Denis Felipe - avatar
+ 1
Billy, C++ supports memory management with smart pointers. It is just not standard yet.
23rd Apr 2017, 2:36 PM
Denis Felipe
Denis Felipe - avatar