Now that we know how to initialize structs and other types in C++, we can take a look at inheritance and learn how to make structs derive from each other. There’s a lot of extended functionality here compared to C# class inheritance. Read on to learn the basics as well as advanced features like multiple inheritance and virtual inheritance!
Posts Tagged interface
C# gives us lots of types of functions for us to call. We must constantly decide between them. Should this function be
static? Should it be
virtual? There are many factors that go into making the decision. Today we’ll look at the function types as a spectrum and hopefully get a little perspective on our options.
Collection types like
Dictionary<TKey, TValue> are fundamental tools in C#. Sadly, I keep seeing the same misuses of them in codebase after codebase. Today we’ll look at the top 5 problems and learn how to easily avoid them!
C# allows for overloading not just function names, but also type names. This is used throughout the .NET and Unity APIs for interfaces like
IEnumerable<T>, classes like
UnityEvent<T0, T1>, and delegates like
Action<T1, T2> and
Action<T1, T2, T3>. C++, however, does not support type overloading. Today’s article explores how to deal with this and, once we’ve solved the issue, what extra C# features we’ll have access to in C++.
So far we’ve had C++ classes that derive from other classes, but not their interfaces. Today we’ll make C++ classes implement all their interfaces to form a full type hierarchy. Along the way we’ll learn about how inheritance works in C++, specifically the esoteric form known as “virtual inheritance.”
Now that we have complete support overriding everything—methods, properties, indexers, events—that can be overridden in a base class or interface, there’s a bit of tidying up to do. In today’s article, we’ll take steps to make base types much more useful by inserting them into their proper place in the type hierarchy.
Today we’ll complete our ability to use C++ classes to derive from C# classes and implement C# interfaces. So far we’ve been able to override methods, properties, and indexers. Today we’ll add the ability to override events and derive from classes that don’t have a default constructor.
Those are the last two pieces of the puzzle that will allow us to derive from any C# base type with a C++ class. Read on for all the details about how this works.
Implementing interfaces and deriving from classes is commonplace in many codebases. Today we’ll make it so C++ classes can implement C# interfaces and derive from C# classes. This means our C++ game code will be able to implement custom
IComparer classes for sorting a
List and derive custom
EventArgs for dispatching in events. Read on to see how this is implemented and how to use it in our projects.