Archiv der Kategorie: C++

Algorithms to use, find and check container elements

The STL algorithms offer a powerful way to solve some base programming use cases. If you know and use these algorithms you can write more clean, efficient and robust code. But unfortunately, it isn’t that easy to know or find … Weiterlesen

Veröffentlicht unter C++ | 1 Kommentar

Public vs. protected vs. private inheritance

In C++ you have three kind of inheritance: public, protected and private. From a technical point of view, they differ in the visibility of methods of the derived class and therefore they influence the interface of the derived class. So, … Weiterlesen

Veröffentlicht unter C++ | Kommentar hinterlassen

Private inheritance creates a “is implemented in terms of” relationship

In C++ we have three kind of inheritance: public, protected and private. Within a previous article I have shown the concepts of public inheritance. By using public inheritance, you can implement your software according to the object-oriented paradigm and create … Weiterlesen

Veröffentlicht unter C++ | 1 Kommentar

Public inheritance always creates an “is-a” relationship

The object-oriented paradigm defines inheritance as a relationship between two classes, were the derived class is a kind of the base class. This logical concept is independent of the programming language. Therefore, object-oriented languages will offer different implementations of this … Weiterlesen

Veröffentlicht unter C++ | 3 Kommentare

logger class in C++

Within this article I want to show some base implementation techniques and demonstrate them in the context of a logging class. The logging class should able to write logging information into a file. The file access should be thread safe. … Weiterlesen

Veröffentlicht unter C++ | Kommentar hinterlassen

int * const x; (const pointer vs. const data)

The example within the title shows a typical pointer declaration containing the const keyword: “int * const x;”. If you write or read such a declaration you may be confused and ask yourself whether the pointer or the data is … Weiterlesen

Veröffentlicht unter C++ | Kommentar hinterlassen

Fast way to return a large object

Within this article I want to think about the question how we can move objects between different scopes without the need of expensive copying and without the need to use an error-prone pointer handling. To analyze this topic, we want … Weiterlesen

Veröffentlicht unter C++ | Kommentar hinterlassen

Type Safety and Resource Safety in C++

If I should summarize the main advantages of C++ in one short sentence I would say: C++ is a completely type safe and resource safe language without performance loss. The type- and resource safety are two very powerful features if … Weiterlesen

Veröffentlicht unter C++ | 1 Kommentar

Arrays and inheritance, a source of errors

If you work with arrays of objects and offer some functions to execute on these arrays, it is common to pass an array pointer and the array size as function parameters. Arrays will often hold a huge amount of data. … Weiterlesen

Veröffentlicht unter C++ | 2 Kommentare

Exception-safe code

During the last years the manner we handle exceptions has fundamentally changed. If we look few years back we will find a lot of applications with exception handling in bigger context only. For example, a module executing a bigger task … Weiterlesen

Veröffentlicht unter C++ | Kommentar hinterlassen