If you’re not familiar with the PImpl (private implementation) idiom, read this Wikipedia article first. While this is more or less “syntactic sugar” since the templates are expanded during compilation, but I think it makes for cleaner looking code.
One of the things that C++ doesn’t have out-of-the-box is events, which is not necessarily a bad thing. However, with the additions to the C++0x/C++11 specification, we can implement something like an event system found in higher level languages such as C# using relatively easy to use code.
If you ask a programmer which programming language you should learn as your first, they’ll often prescribe you their personal favorite, often not considering if the language is supported on multiple platforms, easy to learn, exposing underlying system mechanics, and fully featured.
This post is the first of a series of tutorials intended to teach you the C programming language, an excellent first language because of the following reasons:
Okay, so I know you’re probably here because you searched for “window wrapper class” or something similar and expected the article that I use to host on Scriptionary that threw a bunch of C++ code at you for you to copy and paste. I regret to inform you that the article you were looking for has ceased to exist.
Sorry about that.
However, in its place I have for you this very post which will teach you how to accomplish creating such a wrapper all by yourself. I hope that is okay since all you really need to know is the how to create a window procedure that you can use with your custom class.
This post lists the code for creating a high resolution timer for the Microsoft Windows platform. High resolution timers are often used in multimedia and entertainment applications for timing events up to the microsecond.
This is a heavily modified re-post of the article that used to be on the Scriptionary.com website before the change to the blog, read the source code for details.
Here’s a little snippet I’d like to share with you since there really isn’t a good example online that shows you how to count the processor cores and threads on Microsoft Windows using the Windows API through C++.
Here’s another little snippet that might come in handy in your programmatic travels. I’ll show you an example of usage below, which might also be of interest to you. The code presented is in C, not C++. First, the code to count the amount of digits in an integer:
Edit: Thank you, fixitman for the insightful comment; the code has been fixed to work with non-square arrays as well.
In an effort to produce a better performing multidimensional array, I would like to share the following with you. Say we have a Matrix (or multidimensional array) of 5 x 5 integer elements, M. In order to allocate such an array in C++, we use the following code:
2023 Update: You probably don’t want to use this code since there are likely some serious issues with it. But, fun fact: a major tech company reached out to me to clarify what the license for this is. So, if you want to screw yourself over and use it, let’s say it’s MIT licensed and call it a day.
What: A C++ wrapper around both WINAPI (Microsoft Windows) and PThreads (POSIX threads) functionality.
Why: To abstract cross platform functionality.
Remarks: On windows, CRITICAL_SECTION objects cannot be shared cross-process. This means that the class is tied to your application or DLL process. Comments are in Doxygen/Javadoc style.
This article explains Bitwise Programming in C, a common practice in most programming languages. While bitwise operations might seem like a dark art at first, it really isn’t that scary. You simply need to know when to apply these operations and for what reasons to use them.
The article discusses bits (calculation, workings) in section one previous to the actual operators so that an understanding is made on how bits operate.