Posts Tagged destructor

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 18 – Exceptions

Tags: , , , ,

Like C#, C++ also uses exceptions as one of its main error-handling mechanisms. Today we’ll learn all about them: throwing, catching, their impact on destructors, what happens when they go uncaught, and so much more.

Read the rest of this article »

7 Comments

C++ For C# Developers: Part 12 – Constructors and Destructors

Tags: , , ,

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!

Read the rest of this article »

10 Comments

From AS3 to C#, Part 18: Resource Allocation and Cleanup

Tags: , , , , ,

Today we continue the series by looking at how resources—primarily memory—are acquired and cleaned up in C#. We’ll go way beyond the new operator and discuss advanced features like finalizers and using blocks that can make releasing resources much less prone to errors. Read on to learn!

Read the rest of this article »

No Comments

From AS3 to C#, Part 5: Static Classes, Destructors, and Constructor Tricks

Tags: , , ,

Last week’s article mostly covered abstract classes, but this week we’ll discuss an even more abstract type of class: static classes. We’ll also explore C#’s anti-constructor, known as a destructor, and some fancy ways to construct a class. Read on and learn some more class-related features that were never available to us in AS3.

Read the rest of this article »

9 Comments

From AS3 to C#, Part 4: Abstract Classes and Functions

Tags: , , , , ,

Continuing from last time, this article begins covering features of C# classes that aren’t in AS3. We’ll begin with abstract classes and functions, which AS3 required workaround code to enforce even at run-time. Today’s article shows you how to use C# to cleanly enforce these at compile-time.

Read the rest of this article »

12 Comments