Pages

Friday, 29 May 2020

Chapter 14 // Exercise 2, 3 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 14 // Exercise 2

Try to copy a shape. What happens?

Github: N/A


This usually shouldn't work, however if you're using a recent version of my Graph.h and Graph.cpp files; it does work. Early in Chapter 11, I got annoyed that I couldn't return shapes; so I commented out the constructor that prevents you from doing so. Back then it wasn't explained why he had done it but he does in this chapter and it's to prevent you from attaching shapes to the window in places where the shape can go out of scope. It's useful to be able to return shapes though so I will leave it the way it is.

Chapter 14 // Exercise 3

Define an abstract class and try to define an object of that type. What happens?

Github: N/A


This question is identical to Drill 5. If you make a class and define any part of it as abstract/pure virtual (i.e., '=0') then the compiler will fail to build. Abstract classes must be derived and given definitions in the child classes.

No comments:

Post a Comment