Tuesday, 18 August 2020

Chapter 15 // Exercise 2 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and modified versions of the graphics files used throughout the chapters. You can find those versions through the link below.

Chapter 15 // Exercise 2

Define a class Fct that is just like Function except that it stores its constructor arguments. Provide Fct with "reset" operations, so that you can use it repeatedly for different ranges, different functions, etc.

Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2015/Exercise%202


In this one took me a while as I pondered over how to re-write the points that had already been added to a shape once it's drawn. I thought about deleting the shape and creating a new one but the easiest way was to simply provide a function in Shape that clears the points vector. That way no new shapes are made and StoredFct can just call Function.

No comments:

Post a Comment