100DaysOfGameDev: Day 16

Today, I have spent more time on this series than I planned, definitely more than an hour:) So “why?” you may ask. Because I tried to implement the calculator example from the book on my own, using the newly acquired knowledge on break coding into namespaces and separate files. Yet again, it confirmed my beliefs, that only reading or watching tutorials is not enough, and equivalent practical exercises should be done. It seems trivial on paper, but when I tried to implement it on my own I started to question what I had learned and remembered and had to constantly refer back to the book. However, now I am more confident in my skills to write a calculator language off the top of my head in C++. Also, I felt kinda wrong to only code without reading a bit, considering it was the beginning of “Part III: Abstraction Mechanisms.” Most of the chapter was familiar since I know OOP concepts. Although, there were some C++-specific stuff, that I did not expect to exist. First, it's the idea of the const method, which is a mechanism to guarantee, that method will not modify the member property of an object. However, seems that it does not work for pointers and you can freely modify an object member stored with a pointer. Although, C++ wouldn't be C++ without some weird features. What if you define method const, but still want to modify a property, you declare it to be mutable, absolutely makes sense. Another interesting and unnecessary thing was that if you define the method inside the class's body, then it will implicitly be defined as an inline function, so if you do not want it, then that method should be defined outside. Finally, did I mention how much I hate implicit conversions in C++? For sure I did. Well, it turns out that it's also true for constructor arguments and they even have a keyword for that, just put explicit in front of your constructor, and magic, now no implicit conversion will happen. That's it for today, see you tomorrow!