C++ Learning Journal Week 4

Following straight on from last week I headed into the Inheritance lesson, this taught me about how classes can be derived from other classes allowing them to access their public methods and variables. Why do something like this? Well the book has a diagram to help explain that I’ve chosen to recreate:

11 (2).png

Basically it stated you create a vehicle class that would store the base vehicle properties then the other types of vehicles would derive from the base class. Each have similar features like wheels, speed, lights etc. but they are obviously very different. Inheritance allows us to create the values we need then easily create different types of objects to use/modify them values based on our expectations. We had a lesson on inheritance (in Unity) that used guns as an example, here’s a diagram to map it out:

12 (2).png


At the time I didn’t really understand how inheritance worked or what it can be used for but learning this has definitely opened new doors. Admittedly it was hard to follow and I ended up running into errors that I didn’t really understand so it took longer than expected. But after updating the text adventure and putting it into practice it became slightly clearer.

The Text adventure we added movement so the player can move between rooms (it created a box of rooms at this point). It doesn’t make a very playable game at the minute but it is progress and I’m happy with it. Here’s an image of the project:


I was also happy to learn that the end of this chapter stated the learning could stop there as enough has been taught to cover the project. Which was a relief to hear because I believed I wasn’t making enough progress. It did say the rest of the book was dedicated to the more advanced features of the language and writing more efficient code. Luckily I had time to put into the next chapter covering “polymorphism”.  I’ll be honest I’m still not 100% clear on this subject, the subtopics were fairly straightforward: virtual methods, downcasting/upcasting and interfaces. However, I didn’t quite understand how they worked. It did update the text adventure to make it more efficient and extendable but this is quite upsetting as this is all I had time to do.

I’ve still 2 books covering a lot of the other wonders of C++, even though the learning part of this module is over I may refer back to these books if I get lost throughout the next part (practical). I set out to learn the basics of C++, considering my research and resources I think I’ve done well to achieve this. I will also attempt extending my knowledge and reading further into these books in the near future. There won’t be a post for a while as I progress throughout the next task. However, within the next few weeks there will be an evaluative repot on this entire learning experience.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s