April 25, 2000

DevX

Determining Variable Length

Question: How do I test the number of ‘characters’ contained within a given variable? Answer: Try this: Debug.Print “Length: ” & Len(CStr(X)) Once you convert a variable to a string,

DevX

The unique() Algorithm

STL’s unique() algorithm eliminates all but the first element from every consecutive group of equal elements in a sequence of elements. unique() takes two forward iterators, the first of which

DevX

Signed Bit Fields

A bit field can be signed or unsigned. According to the C++ standard, a signed bit field may be represented in one of three ways: two’s complement one’s complement sign

DevX

Creating Immutable Constants

Although usually I don’t recommend using macros in C++ code, there are a few exceptions. One such exception is when you want to create a truly immutable constant. Consider the

DevX

Undoing a Macro

If you happen to define an object or a function or a constant whose name collides with a macro located elsewhere in a third-party header file, as in: // file

DevX

Take Advantage of Open Source Products

Open source products come with their source code files. Although you can usually install a ready-made executable file, you want to take advantage of the available source code files and

DevX

The Scope of Enumerators

The members of an enumerated type are called enumerators. For example: enum Direction { Up, // an enumerator Down // another enumerator }; int main() {} An enumerator’s scope is

DevX

Porting Code to a Different Compiler

I receive many questions from readers asking for guidance on how to port an existing C++ app to a different compiler or platform. Porting software can be very easy or