Section 11.4

 

Change the first sentence in the first paragraph as indicated in blue:

 

The previous section only provided the definition of a class Packet.

 

Section 11.12

 

Change the final sentence from:

 

To get the overridden method, the parent method needs to be declared virtual (see section 11.18).

 

To:

 

To call the overridden method via a parent class object (p in the example), the method needs to be declared virtual (see section 11.18).

Section 11.13

 

Change the second sentence of the first paragraph as indicated in blue:

 

It is necessary to use super to access properties of a parent class when those properties are overridden by the derived class.

 

 

Change super-class to superclass in second sentence of third paragraph as shown in blue:

 

Whereas superclasses are classes that the current class is extended from, beginning with the original base class.

 

Change second sentence of last paragraph (Note:) as shown in blue:

 

This is because the superclass must be initialized before the current class and if the user code doesn’t provide an initialization,

 

Section 11.14

Change the first and second paragraph as indicated below in blue. Replace everything after the second paragraph with the third paragraph below in blue.

 

It is always legal to assign subclass variable to a variable of a class higher in the inheritance tree. It is never legal to directly assign a superclass variable to a variable of one of its subclasses. However, it may be legal to place the contents of the superclass handle in a subclass variable.

 

To check if the assignment is legal, the dynamic cast $cast() is used (see section 3.14).

 

When used with object handles, $cast() checks the hierarchy tree (super and subclasses) of the source_expr to see if it contains the class dest_var. If it does, $cast() does the assignment otherwise the error handling is as described in section 3.14.

Section 11.15

Change the second sentence of the first paragraph as indicated in blue:

 

The first, implicit action new() takes is to invoke the new() method of its superclass, and so on up the inheritance hierarchy.

 

Change the first sentence of the second paragraph as indicated in blue:

 

If the initialization method of the superclass requires arguments, one has two choices.

 

Change the first sentence of the fourth paragraph as indicated in blue:

 

A more general approach is to use the super keyword, to call the superclass constructor:

Section 11.18

Add the following to the beginning of the last paragraph.

 

An abstract class may contain methods for which there is only a prototype and no implementation (i.e., an incomplete class). An abstract class cannot be instantiated, it can only be derived.

 

Change the last sentence of the last paragraph as indicated in blue:

 

However, if the subclass overrides the virtual method, then the new method must exactly match the superclass’s prototype.

Section 11.19

Change the first sentence of the first paragraph as indicated in blue:

 

Polymorphism allows one to use superclass variables to hold subclass objects, and to reference the methods of those subclasses directly from the superclass variable.