October 2019
Beginner to intermediate
498 pages
14h 13m
English
Now that you have a better understanding of how inheritance works, let’s try a slightly more difficult test program. LISTING 12.7 contains a simple function called test2 to draw two lines that cross. Once the lines are drawn, the color of the first line is changed to red and the width of the second line is changed to 4. What do you think the final picture will look like?
LISTING 12.7 Drawing two lines that cross
If you think that the result should be two crossing black lines, one of which is thicker than the other, you are correct, as FIGURE 12.7 shows. Why didn’t the call to setColor actually change the color of line1 ...
Read now
Unlock full access