C++ is really awesome programming language that has many options to use variables in a way which can make your C++ App use less memory and app size. In this post, we explain what are a constant, a constant expression and generalized constant expressions in modern C++.
What is the const constant keyword in modern C++?
Let’s remember that, in C++ there are two ways to define constants.
What Is The alignas Alignment Specifier In Modern C++?
March 28, 2023
One of the features of Modern C++ is Alignment Support which comes with the C++11 standard. One of the new features of this support is a new keyword alignas which is the alignment specifier. For example, we can apply the alignas alignment specifier to define the minimum…
What is a Forward Declaration enum Enumeration in C++?
March 27, 2023
Understanding how to correct declare variables is important in programming, especially in a modern C++ Application. There is an enumeration method that allows you to easily enumerate (count or determine their place in an order) values in variables. In C++, enumeration is…
Is C++ A Functional Programming Language?
December 19, 2022
C++ is highly evolved and mature programming language. The C++ language has a great set of choices of modern C++ IDE and compilers all of which come with a lot of tools, GUI components and libraries.
By using C++, you can create functional programs to solve complex engineering problems, you can simulate and analyze with 2D/3D graphics, create 3D environments, and add your custom 3D objects…
The Main Function of a C++ Program
December 27, 2020
The source code written in C++ must be compiled (i.e. translated to the machine code) by one or another compiler such as Embarcadero RAD Studio C++ compilers before in can be runned. In general, there are two types of the resulting machine code: library and main executable…
Traversing sequences without writing explicit loops
December 26, 2020
The posts General Loop Statements in Modern C++ and Range-for-statement in modern C++ cover ways to write explicit loops. But explicit loops can be tedious to write and, what is more important, – harder to read, because the resulting code requires to spend the extra…
General Loop Statements in Modern C++
December 25, 2020
Each loop statement in C++ has its loop body which is executed repeatedly until the loop condition expression that yields a loop condition becomes false (otherwise, the loop will run “forever”). The statement continue can be used to interrupt the current iteration and skip the rest of the loop body to immediately check the loop condition before continuing. A whole loop statement can be…
Switch Statement in Modern C++
December 20, 2020
The C++ language provides the switch statement which can be used to replace the set of if statements (see If Statements in Modern C++). First of all, let’s define the enum type Traffic_light_color as follows:
enum class Traffic_light_color { red, yellow, green…
Introduction to Random Number Generation in Modern C++
December 13, 2020
Every implementation of the C++ Standard Library like one included to Embarcadero RAD Studio C++ compilers provides two ways for (pseudo-)random numbers generation: old-fashioned facilities from <cstdlib> and modern facilities provided by <random>.
Facilities…
Helpers for Generic C++ Code Iterating Over Sequences
December 12, 2020
The iterator library that is part of the C++ Standard Library provides the following helpers for writing generic code:
#include <iterator> // helpers are defined here
template<class Container>
void foo(Container& c)
{
// Generic way to obtain (constant) iterators
auto b = std::begin(c); // (1)
auto cb = std::cbegin(c); // (2)
auto e = std::end(c); //…