Posts Tagged inheritance

C++ For C# Developers: Part 15 – Struct and Class Permissions

Tags: , , , , ,

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.

Read the rest of this article »

1 Comment

C++ For C# Developers: Part 14 – Inheritance

Tags: , , , , ,

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!

Read the rest of this article »

3 Comments

DIY Virtual Functions in Burst

Tags: , , , , ,

Now that we’ve seen how function pointers work and perform in Burst, let’s use them to build a higher-level feature: virtual functions!

Read the rest of this article »

3 Comments

C++ Scripting: Part 29 – Factory Functions and New MonoBehaviours

Tags: , , , ,

Since their introduction in part 7, support for C++ MonoBehaviour messages has always been a special case. The reason for this was that we didn’t have good enough support for what I’m calling “factory functions.” These are functions like GameObject.AddComponent<T> that instantiate a generic type. This week we’ll go over why that support was lacking, what was done to fix it, and how the new system works.

Read the rest of this article »

No Comments

C++ Scripting: Part 25 – Full Type Hierarchy

Tags: , , ,

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.”

Read the rest of this article »

No Comments

From AS3 to C#, Part 2: Extending Classes and Implementing Interfaces

Tags: , ,

Let’s continue the From AS3 to C# series from last time by continuing to investigate C# classes from an AS3 developer’s point of view. Today’s article will cover class inheritance, interface implementing, and interface inheritance.

Read the rest of this article »

15 Comments

The Right Way to Check An Object’s Type

Tags: , , , , ,

There are lots of ways to check the type of an object in AS3. These include the is operator, the deprecated instanceof operator, the constructor field, and a combination of getQualifiedClassName and getDefinitionByName. Which is fastest, cleanest, and most effective? Today’s article puts them all to the test to find out!

Read the rest of this article »

5 Comments

Better Ways To Check Class Inheritance

Tags: , , ,

If you want to check if one class inherits another without actually having instances of those classes, you may have read my article on Checking Class Inheritance. However, as the many comments quickly pointed out, the methods of checking this may have some flaws. There were also additional methods posted in the comments that should be added and tested. Today I’m adding them, testing them, and checking all of their validity to find the ultimate approach to check class inheritance.

Read the rest of this article »

2 Comments

Checking Class Inheritance

Tags: , , , , ,

I recently received a tip about a thread discussing an interesting problem: how to tell if one Class object represents a class that subclasses another Class object. If you had an instance of the class, you could simply use the is or instanceof keywords, but that won’t do here. Today’s article shows how to solve this tricky problem.

Read the rest of this article »

20 Comments

Runnables as Function Pointers

Tags: , , ,

Last Friday’s article expressed some longing for C-style function pointers. It attempted to use AS3’s Namespace class to fake a function pointer. Unfortunately, this resulted in far slower code than simple direct access. Today’s article shows a technique that actually results in far faster code!

Read the rest of this article »

16 Comments