100DaysOfGameDev: Day 3

Day 3 wasn't less productive and I managed to cover a set of topics including references combining lvalues and rvalues and more pointers, and a lot of structs. Hi, my name is reference, friends usually call me T& where T is my type. I may look simple, but sometimes I'm lvalue orrr rvalue. To be more technical lvalue reference, refers to an lvalue, to which the user of reference can write. Its brother is a bit weird at first glance, but it's quite useful and its name is “rvalue reference*, which refers to a temporary object, where the user of reference can modify it assuming the object will never be used again. I wonder if it was the end of the world, then we would all be rvalues. In short, you would use rvalue reference, when you do not want to copy the value of something that will be lost anyway, but rather you store that value for your usage. Not confusing at all right? Awesome, since you're here, I'm gonna introduce you to our neighbor Mr. Structs. Say hi to Mr. Structs. Hi, Mr. Structs with a screeching voice. Mr. Structs is like Mrs. Class, but more public. Also, Mr. Structs has a history waaay back in the ages of C, where it was used to store data. I've typed too much already, so will tell you two things. Pay attention to your struct layout to have fewer holes and save some memory. Structs can be used as “Plain Old Data” with cool bit-fields and you can use memcpy() and call yourself a hardcore programmer. Also, struct arrays are cool and in C++ your structs can have a bunch of other stuff, besides fields. That was three things, but well not removing it anymore. See you!