Pages

Friday, 13 March 2020

Notes on the examples in Chapter 12 Programming:Principles and Practice Using C++

So I've started reading through Chapter 12 and just trying to get the first example shown a page in took me a while. Therefore, I'll be leaving comments and fixes in this post for anyone else who may have struggled.

In order to get the program running in the first place you'll need some files made by Bjarne himself. I spoke about these in a previous post and fixed them up and posted them to my Git. There were a lot of errors as, due to time they have become wildly out of date.

These cleaned up files can be found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

And I wrote about this process in detail here:
https://lptcp.blogspot.com/2020/03/programming-principles-practice-fixing.html

I wrote a guide for installing FLTK here as well:
https://lptcp.blogspot.com/2020/03/how-to-install-fltk-for-use-with.html

12.3 - A First Example pg 415
Due to namespace ambiguity, it's probably best if you avoid using namespace Graph_lib. In the first example in 12.3, Polygon is considered ambiguous and requires Graph_lib even though the using keyword has been set.  That was the only issue I had for the first example.

12.7.3
Initially, the axis drew as light grey on my screen. I tried looking for the definition but I couldn't seem to find where it is initially set to use grey, so I just left it. I then remembered that we're supposed to be hitting "next" after every example to show it building up. The key is to make sure you have win.wait_for_button() after every example. The axis shows as black after that.

I also noticed that the canvas label disappears after the first screen. Odd. (edit 30/09/2020 - I ended up fixing this here: https://lptcp.blogspot.com/2020/08/notes-on-chapter-15-principles-practice.html)

12.7.5 - 12.7.6
Both Rectangle and Polygon will need their scope (Graph_Lib) when using them. Even if you have using namespace Graph_lib;

12.7.7
The green shade is much brighter than the one printed.

12.7.10
Ellipse also needs Graph_lib::

You can find the full code and images I used here:
https://github.com/l-paz91/principles-practice/tree/master/Chapter%2012/Examples

No comments:

Post a Comment