Rvalue References

Rvalues and Lvalues The terms lvalue and rvalue do not typically come up often for most programmers. Occasionally you might see a compiler error message about rvalues. Other than that, it is not something you generally have to worry about. If we consider the simple assignment: a = b there is an obvious symmetry; a … Read more

Delegating Constructors

In some situations, it’s useful to provide more than one way to initialise an object. When we choose to provide more than one constructor, we want to avoid having to duplicate code. Consider the following example of a simple 2D vector class, which can be initialised either by passing in two doubles, or a double … Read more

Range-based Loop Syntax

The C++ standard library comes with a host of useful container classes. However, using these classes means becoming familiar with the language of templates. Simply iterating through a collection requires the use of some quite verbose syntax. For example, suppose we have a vector of integers: std::vector<int> intArray; In C++03, the contents of the vector … Read more