Both languages have both deconstructing (var (x, y) = vec;
) and attributes ([MyAttribute]
). C++ differs from C# in several ways, so today we’ll take a look at those differences and learn how to make use of these language features.
Posts Tagged struct
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!
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 const
.
With constructors under our belts, we can now talk about initialization of structs and other types. This is a far more complex topic than in C#. Read on to learn a lot of nitty-gritty details!
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!
Now that we’ve covered the basics of structs, let’s add functions to them! Today we’ll explore member functions and overloaded operators.
Let’s continue the series today by starting to look at structs. These are far more powerful in C++ than in C#, so today we’ll start with basics like defining and initializing them. Read on to get started!
Job structs can’t contain managed types like string
, 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.
An 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!