This post continues and explains the previous post.
In the example from the previous post, our base class has invoked a virtual function during the construction of the object, expecting that the correct function would be called. Why was that an error, you ask ?
Continue reading Virtual dispatching within a constructor/destructor
Find below a post on the topic of file signatures, also known as Magic Numbers. The provided code snippet contains an error for the reader to discover and point out.
Continue reading Checking file signature
I’ll assume you are already familiar with the concept of namespaces, and the using keyword. So let me try and introduce some of the less common features of the namespace mechanism.
Continue reading Everything about namespaces
This article will discuss references to temporary objects – a mechanism with a few subtleties.
Continue reading Reference to temporary
When we approach the process of designing our software, there are many issues we must address in order to be successful. One of these issues (and you are free to disagree) is: How will we be able to test (or debug) our hand crafted piece of code?
This post will attempt to at least provide one way of writing code that is a little easier to debug and test, by making use of the factory design pattern.
Continue reading Designing for testability: factories
I am a little busy nowadays, so excuse me for posting yet another somehow basic article. However, I still retain the hope that some of you are not familiar enough with at least one of these two keywords in C++.
Continue reading Mutable and volatile
As promised, this article continues and provides a thorough explanation of the previous post.
Continue reading Substitution failure is not an error, part II
Explanation on what is SFINAE can be found at wikipedia. I’ve tried to write my own explanation but ended up with the conclusion that it’s best described there, and I wouldn’t want to copy&paste stuff. If you have any question marks floating around your heads, please don’t hesitate to ask.
SFINAE is used a lot in meta-programming. For example, you will be able to find many constructs in boost that are making use of this idea.
I’ve come across a pretty nice and complex use of SFINAE on stackoverflow the other day. The code below generates a templated class HasX, whose member HasX::value denotes whether the class T has a member (data or function) called x, or not. Let me introduce the code, and an explanation will follow.
Continue reading Substitution failure is not an error, part I
How would you like the next piece of code?
??=define A "hey"
int main () ??<
char x??(??) = A;
if (0 ??' 1)
std::cout << x << std::endl;
// what do you say about this code??/
std::cout << "amusing" << std::endl;
Continue reading Trigraphs
Let’s have a better look at native arrays.
Continue reading More on arrays