Why You Should Use Class Enums in C++

This post was originally published on Admiral Ackbar’s Code Emporium .

This is a brief post about what class enums are in C++, and why you should use them.

The Problem: Enums Pollute Global Scope

Here’s a conflict you might get when using enums:

enum computer_state { ON = 0 , OFF, STANDBY };
enum disco_ball     { OFF = 0, ON };

int state = ON; //CONFLICT - this won't compile

read more

How to Have Multiple Versions of C++ OpenCV Side by Side

This post was originally published on Admiral Ackbar’s Code Emporium .

This tutorial will show you how you can have different versions of the same library side by side such that it’s easy to change which version your code uses.

For example, I work a lot with OpenCV, the computer vision library. I like to be able to try out different features in the trunk version of the library, but prefer to use a stable release in production settings. It’s actually pretty easy to have both versions on your computer, and select which one you’d like to use at compile time.

The following assumes you’re on a Linux machine. I’ll use OpenCV as an example, but the concept applies to any library.

read more