C++ Learning Journal Week 3

Firstly I apologise for this slightly late post, I’ve been ill the past few weeks and working on this alongside the holidays & other projects has been a battle. However, I’ve covered a lot this week and made some good progress, let’s begin.

This week I’m back in the book, this began with functions and learning how they work in C++, this went well as they work almost identically to C#. I did still learn about returning values which is something I hadn’t used before. It also covered passing pointers through the parameters and passing by reference. This uses the reference operator ‘&’ which allows a function to modify the value passed through (rather than creating a copy). Example:


Next came enums, something I’d used before but wasn’t 100% clear with. Interestingly I managed to use it within another project (C#) after learning how they work. The next chapter covered loops and flow control; I’m not going to talk much about this as it’s pretty basic (if/switch statements, for/while loops etc.) which I’d learnt throughout my studies previously. I simply had to understand the differences between how they’re written out within C++.

I then got introduced to namespaces and header files, a new concept to me; I know Unreal works with these so I was eager to begin. This lesson ended by modifying the layout of the text adventure.

Then it moves to OOP (Object-Oriented Programming), a topic recommended to learn during my research in task 1. I struggled following at first which made the process last longer than intended. But after reading over it a few times I began to understand the topics it was covering. Including: Encapsulation, Constructors/Destructors, Method Overloading & Operator Overloading. It’d be difficult describing how each work, but I used what I’d learned and refined the Text adventure so the project works with classes improving: readability, efficiency and ease of use. Below there’s a screenshot of the file currently:


Admittedly it doesn’t look like much but it’s built to be extended, currently it:

  • Outputs a welcome message
  • Asks the player to input their name
  • Provides instructions
  • Uses loops to allow players to continuously input until a correct choice is made.

Finally, the book covered data & access modifiers; here I learned how to use the static, const, friend & mutable keywords. This included making a simple program incrementing a counter within a class. It showed how we can access values within a class utilising these keywords or create static functions that can be called from anywhere by simply calling it:


I’ve only a week left of learning; I’ll partially review my learning next week as well as progress further into the book in hopes of learning as much as possible. The first lesson coming up next week is inheritance which promises to extend the text adventure a lot into something slightly more playable. I am looking forward to taking this as far as I can get it.

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