Need to store objects in an STL container? Need polymorphic behaviour meaning you’ll need to store pointers to a base class? Want to use a smart pointer to avoid memory leaks? Planning on using auto_ptr because it’s available as part of C++? Before you go any further, try this little quiz.
Ubiquitous use of smart pointers can prevent memory leaks and make for much easier to read and understand code. Unfortunately, as with most things C++, there are some caveats you need to be aware of otherwise your attempts to write robust code could very well come back to bite you. This little quiz shows how careless misuse of auto_ptr could open up a big can of worms.
When working with STL containers we generally use iterators to access, manipulate and enumerate the contents. This almost becomes second nature and it’s very easy to go on auto-pilot and end up coding an innocuous looking bit of code that can contain a rather nasty surprise. This little quiz shows just one example of how such a surprise might come back to bite you.
One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property. These are like data members except they can have preconditions imposed on them prior to getting or setting their value.
This article is aimed at someone who has never used IRC before. It covers the very basics of setting up and configuring a client and a little bit about starting a channel and the basics of being a channel operator. What it doesn’t do is review or promote any of the various IRC clients available. Nor does it cover power users; however, suitable reference material is suggested at the end for eager readers.
Complaining. It’s easy right? Anyone can do it. You just raise your voice and talk loudly, or maybe even shout at the object of your frustration until your problem gets sorted. If that is all it takes, then that’s it, end of article. Wow, that was easy!
The C++ language is a context sensitive language, which means a compiler cannot always decide the semantics of a line of code in isolation. Sometimes, though, it is impossible for the compiler to make up it’s mind so it just guesses. Yup, that’s right, it guesses. To find out more try this little quiz.
In general, it’s pretty obvious what order the compiler will initialize variables: it’s the order in which they appear in the translation unit. What happens, though, when you have a global variable in one translation unit depending on the the initialization of a global variable in another translation unit? This little quiz explores just that.
What could be as simple as incrementing a variable by one? Ignoring overflow, what else could possibly go wrong? As it turns out, quite a lot as this little quiz demonstrates.
There are various dangers when casting pointers to different types but as a general rule, casting to a void pointer and back to the original pointer is considered safe. Unfortunately, this is not always the case as this little quiz demonstrates.