April 2024
Beginner to intermediate
500 pages
24h 20m
English
Now that you have a better understanding of how inheritance works, let’s try a slightly more difficult test program. Session 12.4 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?
Session 12.4 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 ...
Read now
Unlock full access