C++ allows one class to inherit two or more base classes at the same time. Java does not. To understand the difference, consider the two hierarchies depicted here: In both cases, s
Read tutorial ↗One extensively used feature of C++ that Java does not support is default function arguments. For example, the area() function shown in the following C++ program computes the area
Read tutorial ↗One of the most innovative aspects of Java is the interface. An interface specifies the form of its various methods without specifying any implementation details. Each class that i
Read tutorial ↗The C++ pointer parameter, In Java, became a reference parameter. Of course, C++ also supports reference parameters. As mentioned, most pointer parameters found in C++ code are sim
Read tutorial ↗Conceptually, converting C++-style pointer-based array accessing into the equivalent Java-compatible array indexing is straightforward—simply substitute the appropriate array-ind
Read tutorial ↗For the most part, it is quite easy to convert a C++ function that uses pointer parameters into its equivalent Java method. Since Java passes all objects by reference, sometimes th
Read tutorial ↗A reference is an alias; when you create a reference, you initialize it with the name of another object, the target. From that moment on, the reference acts as an alternative name
Read tutorial ↗You can use the keyword const for pointers before the type, after the type, or in both places. For example, all of the following are legal declarations:
Read tutorial ↗One source of bugs that are nasty and difficult to find is stray pointers. A stray pointer is created when you call delete on a pointer--thereby freeing the memory that it points t
Read tutorial ↗Every class member function has a hidden parameter: the this pointer. this points to the individual object. Therefore, in each call to GetAge() or SetAge(), the this pointer for th
Read tutorial ↗Normally you can access data members and functions by using the dot (.) operator for Cat objects created locally. To access the Cat object on the free store, you must dereference t
Read tutorial ↗The program below demonstrates allocating a variable on the heap, using that variable, and deleting it.
Read tutorial ↗