Posts Tagged operator overloading

C++ For C# Developers: Part 22 – Lambdas

Tags: , , , ,

Both C++ and C# have lambdas, but they have quite a few differences. Today we’ll go into how C++ lambdas work, including all their features and how they compare and contrast with C# lambdas. Read on to learn all the details!

Read the rest of this article »

2 Comments

C++ For C# Developers: Part 19 – Dynamic Allocation

Tags: , , , ,

So far, all of the memory our C++ code has allocated has either been global or on the stack. For the many times when the amount of memory isn’t known at compile time, we’ll need dynamic allocation. Today we’ll go over both the basics of new and delete, but also dive into some advanced C++ features such as overloading new and “placement” new.

Read the rest of this article »

5 Comments

C++ For C# Developers: Part 16 – Struct and Class Wrapup

Tags: , , , , ,

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!

Read the rest of this article »

2 Comments

C++ For C# Developers: Part 11 – Struct Functions

Tags: , , ,

Now that we’ve covered the basics of structs, let’s add functions to them! Today we’ll explore member functions and overloaded operators.

Read the rest of this article »

3 Comments

Optional<T>: A Nullable<T> Alternative

Tags: , , , , ,

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!

Read the rest of this article »

2 Comments

C++ Scripting: Part 18 – Array Index Operator

Tags: ,

When we covered arrays in part 14, we skipped implementing the [] operator with them. Instead, we opted for a simpler pair of GetItem and SetItem functions. Today we’ll address that oversight so our C++ game code can index arrays just like in C#.

Read the rest of this article »

No Comments

C++ Scripting: Part 13 – Operator Overloading, Indexers, and Type Conversion

Tags: , , ,

Today’s article continues the series by adding support for C++ to call the various overloaded operators and indexers that are written in C#. This includes support for all 24 overloadable operators in C# plus the explicit and implicit type conversion operators. Indexers aren’t quite overloaded operators, but they allow for array-like indexing into C# types so they’re included today. Read on to learn how all this support was implemented in the GitHub project!

Read the rest of this article »

No Comments

From AS3 to C#, Part 7: Special Functions

Tags: , ,

Last week we discussed extension methods and virtual functions and today we’ll continue with more special kinds of C# functions. We’ll cover operator overloading, out parameters and reference parameters.

Read the rest of this article »

4 Comments