Section 1 Part B of the Train2Game Game Developer course has been very exciting for me. It’s been through a lot of principles that I’ve used in my development, but instead of just teaching me what I know, It’s gone in to a lot more detail that has helped clarify things. Here is a quick overview of what the lessons taught and what I gained from them….
I knew how to create functions and pass through variables to them, but I learnt more on the types of arguments used, passing by value and by reference and how powerful these different types can be. The other aspect of functions and loops is how to gain and release control using keywords such as break; and return;.
Another intersting thing was with default parameters and the order in which they need to be placed in the argunment list, making sure that and defaults are placed to the right and other parameters that have no defaults are first at the left.
For lesson 4 I obtained a score of 100%.
I got a little confused in parts of this lesson and had to reread quite a few parts of it. And it turns out that I still didn’t have a full understanding of overloading and prototypes.
Overloading went in to having the same function names, but each function took different arguments, for example
void ResetPlayerLives(int playerLives)
int var1 = playerLives;
void ResetPlayerLives(float playerLives)
float var1 = playerLives;
And then the program works out which one to call based on what is sent through, eg.
ResetPlayerLives(2); // Will call the int version
ResetPlayerLives(2.0f); // Will call the float version
That’s it in the simplest form. You can then overload operators. This is where I got a little confused, but after receiving the comments back from the TMA, it made me revisit the information and understand it a lot better.
Looking at header files in C++ was useful. It advised how they are used and what the usual preference is for having them. Usually to put in prototypes and other global variables that will be used within the .cpp file. In theory all the code could go in a header file, but it’s not good practise.
And the last part of this lesson was on Recursion, the way of having a function call itself until a certain criteria is met. It’s still a bit puzzling, but I guess until I come to code something that uses recursion then I will not fully understand how easy or complex it is to use it in a solution.
For lesson 5 I obtained a score of 80%.
Questions and answers I got wrong:
Question 15: Overloaded functions must not use reference variables.
True (A) is the wrong answer. Reference variables do not factor. The key is that when overloading we now have two versions of the same function, each with the same name. The correct answer is False (B).
Question 16: If we prototyped a function like this, would it be legal?
void myfunc( int, float );
No (B) is incorrect. This is not illegal. The correct answer is Yes (A).
Question 17: Which of these function prototypes will overload the > operator successfully?
A void operator > ( highscore one, highscore two );
B bool operator > ( highscore, highscore );
C highscore operator > ( highscore, highscore );
void operator > ( highscore one, highscore two ); (A) is incorrect. No this is not the correct syntax. The correct answer is bool operator > ( highscore, highscore ); (B).
Question 18: Which of these function prototypes will overload the + operator successfully?
A void operator + ( highscore one, highscore two );
B bool operator + ( highscore, highscore );
C highscore operator + ( highscore, highscore );
void operator + ( highscore one, highscore two ); (A) is wrong. This example shows the incorrect syntax. The correct answer is highscore operator + ( highscore, highscore ); (C).
This lesson was all about Classes. I understood classes previously from coding up the C# programs, but there were little things that I had either missed or didn’t understand that this lesson clarified for me.
How you can set parts of a class to be accessible by other parts of the program was also interesting. Setting sections to be private, protected or public, and how friends were setup and how they could override some of the accessible levels set.
For lesson 6 I obtained a score of 100%.
So far with the scores of all lessons I am averaging 92.9%. I’m really happy with this and still enjoying this course. Again, a lot of it has been theory and looking at code examples rather than getting stuck in and coding things up myself. But with the information I’ve picked up, it will certainly help with any coding I am doing outside of this course.
Awaiting my Section 1 Part C document to come through now.