Today we’ll wrap up structs and classes by discussing a bunch of miscellaneous features: local classes, unions, overloaded assignment operators, and user-defined literals. C# doesn’t have any of these features, but it can emulate some of them. Read on to learn a bunch of new tricks!
Posts Tagged struct
Today we’ll cover the last major topic of structs in C++: how we control access to them. We’ll talk about access specifiers like
private, the “friendship” concept, and finally get around to the details of
So far with structs we’ve covered data members, member functions, and overloaded operators. Now let’s talk about the main parts of their lifecycle: constructors and destructors. Destructors in particular are very different from C# and represent a signature feature of C++ that has wide-ranging effects on how we write and design code for the language. Read on to learn all about them!
Job structs can’t contain managed types like
class instances, or delegates. This is currently a pain as a lot of the Unity API relies on these and so we’re forced to deal with them. Today we’ll talk about how we can use managed types in our jobs to bridge the gap.
int can be anything: points, health, currency, time, etc. We often make mistakes using one
int where another
int was supposed to go. Imagine a function
DoDamage(int, int). It’s not obvious what the parameters mean. Today we’ll use the C# type system to make the code much more readable and less error-prone!
Today we’ll make a new type that addresses some of the deficiencies in
Nullable<T>. We’ll end up with a good tool for dealing with operations that may or may not produce a result or take a parameter, even in Burst-compiled code. Read on to see how it works!