...

/

Copying and Assignment

Copying and Assignment

Get to learn about copying and assignment of class objects.

We'll cover the following...

Copying

Copying affects only the variables, not the object.

Because classes are reference types, defining a new class variable as a copy of another makes two variables that provide access to the same object. The actual object is not copied.

Since no object gets copied, the postblit function this(this) is not available for classes.

auto variable2 = variable1;

In the code above, variable2 is being initialized by variable1 and the two variables start ...