-
C++ Type Casting
What is Type Casting? In software development, a “type cast” is an operation that converts an object to a different type. An example of this would be converting a variable of type int to double. Most object-oriented languages offer some form of type conversion or type casting, especially C++. This article will go over the…
-
C++ Strings
The string is a fundamental data type in many programming languages. In C++, a string is a data type that can store a sequence of characters. Despite being so ubiquitous and fundamental, strings are not primitive data types. To use a string in C++, you must include the <string> header from the standard template library…
-
Examining Smart Pointers
Memory management is crucial to designing reliable and efficient software. Mismanaging memory can lead to buffer overflows, segmentation faults, and memory leaks. Sometimes, mismanaging memory can be gravely detrimental, leading to exploitable vulnerabilities that malicious actors can leverage as attack surfaces. Raw Pointers Pointers are variables that are used for tracking the memory address of…
-
The Curiously Recurring Template Pattern
The Curiously Recurring Template Pattern (CRTP) is a C++ design pattern that exhibits some interesting behavior related to inheritance and polymorphism. It is considered an idiomatic design pattern, meaning it incorporates semantic design principles for efficiently implementing a recurring construct. In this instance, CRTP is heavily tied to C++ given the language features that C++…
-
The pImpl Pattern
Certain class implementations carry with them a lot of compile-time dependencies, and making changes to those will require recompilation of everything that uses a representation of the class. The pImpl (pointer to Implementation) pattern alleviates compile-time dependencies by moving all the implementation-level details of a class into a different class that is accessible via an…
-
The Singleton Pattern in C++
A singleton is a class that does not allow for dynamic instantiation. At runtime, one instance of the class is statically initialized, and this instance cannot be copied or assigned. To use the object, an accessor method is provided within the class definition to allow another portion of the program to grab a reference. Here…