Skip to content
evilrix

evilrix

Mostly Coding

  • About
  • Copyright

Category: Coding

Stuff to do with programming

The dangers of iterators

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “The dangers of iterators” →

How to add properties to standard C++ classes

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “How to add properties to standard C++ classes” →

Definition or a declaration?

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “Definition or a declaration?” →

Order of initialization

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “Order of initialization” →

When simple arithmetic isn’t so simple!

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “When simple arithmetic isn’t so simple!” →

The dangers of casting pointers

02/12/2012 ~ evilrix ~ Leave a comment

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.

Continue reading “The dangers of casting pointers” →

String literals and pointers

02/12/2012 ~ evilrix ~ Leave a comment

Do you know how to access c-style literal strings? Try this two-part quiz and see if you are able to unravel the different semantics of character pointers and arrays.

Continue reading “String literals and pointers” →

Exceptions to the rule

02/12/2012 ~ evilrix ~ Leave a comment

The C++ Standard is a pretty large and complex document; however, it is the bible as far as writing C++ code is concerned. The standard is full of exceptions that prove the rule, and this quiz demonstrates just one trivial example.

Continue reading “Exceptions to the rule” →

Comparing structs

02/12/2012 ~ evilrix ~ Leave a comment

This little quiz explores the pitfalls of trying to compare structs. Do you know the right way to check if two structs are the same?

Continue reading “Comparing structs” →

Copying to stdout using STL

02/12/2012 ~ evilrix ~ Leave a comment

The STL (Standard Template Library) is a collection of generic algorithms and data structures. This little quiz demonstrates one of the many useful things one can achieve with just a few lines of code when utilizing the power of this library.

Continue reading “Copying to stdout using STL” →

Posts navigation

Older posts
Newer posts

My Résumé

  • Facebook
  • X
  • Threads
  • Last.fm
  • Spotify
  • Goodreads
  • Instagram
  • Medium
  • GitHub
  • LinkedIn

Subscribe

 Subscribe to feed

Search

Categories

  • Coding
  • Personal
  • Tutorials

Tags

algorithms boost c++11 cpp data structures humour irc oop opinion python rant spam templates unicode work

Recent

  • Bloom Filters
  • When is Unicode not Unicode? When Microsoft gets involved!
  • C / C++ main function prototypes
  • C++ Catching exceptions in constructors
  • C++ Throwing exceptions from destructors

Archives

  • October 2017
  • May 2015
  • April 2015
  • February 2014
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • May 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 36 other subscribers

Recent Comments

Briana Cooper's avatarBriana Cooper on A sad day for scrobbles e…
Kelly's avatarKelly on Determining if a C++ type is c…
Paula's avatarPaula on The Cookie Monster!
Zbynek Novotny's avatarZbynek Novotny on Functional programming using…
Unknown's avatarFirst Direct passwor… on Is your password salty en…

Meta

  • Create account
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com
Blog at WordPress.com.
evilrix
Blog at WordPress.com.
  • Subscribe Subscribed
    • evilrix
    • Already have a WordPress.com account? Log in now.
    • evilrix
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...