September 2011
Beginner
650 pages
15h 47m
English
In the preceding programs, the following line was used to declare an object of type Vehicle:
![]()
This declaration performs two functions. First, it declares a variable called minivan of the class type Vehicle. This variable does not define an object. Instead, it is simply a variable that can refer to an object. Second, the declaration creates a physical copy of the object and assigns to minivan a reference to that object. This is done by using the new operator.
The new operator dynamically allocates (that is, allocates at run time) memory for an object and returns a reference to it. This reference is, more or less, the address ...
Read now
Unlock full access